diff --git a/src/main/kotlin/blocks/implementation/ZBlock.kt b/src/main/kotlin/blocks/implementation/ZBlock.kt new file mode 100644 index 0000000..ae23464 --- /dev/null +++ b/src/main/kotlin/blocks/implementation/ZBlock.kt @@ -0,0 +1,24 @@ +package blocks.implementation + +import blocks.Block +import blocks.Rotation +import movements.Direction +import movements.Position + +class ZBlock(private val initialPosition: Position): Block { + + private val positions = listOf(Position(0,0), Position(0,1), Position(1,1), Position(1,2)) + + override fun getNeededPositions(): Collection { + return positions.map { position -> position.addAxes(initialPosition) } + } + + override fun rotate(degree: Rotation) { + TODO("Not yet implemented") + } + + override fun move(direction: Direction) { + TODO("Not yet implemented") + } + +} diff --git a/src/test/kotlin/blocks/ZBlock/ZBlockTest.kt b/src/test/kotlin/blocks/ZBlock/ZBlockTest.kt new file mode 100644 index 0000000..9e65106 --- /dev/null +++ b/src/test/kotlin/blocks/ZBlock/ZBlockTest.kt @@ -0,0 +1,37 @@ +package blocks.ZBlock + +import blocks.implementation.ZBlock +import movements.Position +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class ZBlockTest { + + @Test + fun `position 0,0 needed positions are (0,0), (0,1), (1,1), (1,2)`() { + val zBlock = ZBlock(Position(0,0)) + assertEquals( + listOf(Position(0, 0), Position(0, 1), Position(1, 1), Position(1, 2)), + zBlock.getNeededPositions() + ) + } + + @Test + fun `position 0,1 needed positions are (0,1), (0,2), (1,2), (1,3)`() { + val zBlock = ZBlock(Position(0,1)) + assertEquals( + listOf(Position(0, 1), Position(0, 2), Position(1, 2), Position(1, 3)), + zBlock.getNeededPositions() + ) + } + + @Test + fun `position 1,0 needed positions are (1,0), (1,1), (2,1), (2,2)`() { + val zBlock = ZBlock(Position(1,0)) + assertEquals( + listOf(Position(1, 0), Position(1, 1), Position(2, 1), Position(2, 2)), + zBlock.getNeededPositions() + ) + } + +} \ No newline at end of file