diff --git a/src/main/kotlin/blocks/implementation/SBlock.kt b/src/main/kotlin/blocks/implementation/SBlock.kt new file mode 100644 index 0000000..926cd84 --- /dev/null +++ b/src/main/kotlin/blocks/implementation/SBlock.kt @@ -0,0 +1,22 @@ +package blocks.implementation + +import blocks.Block +import blocks.Rotation +import movements.Direction +import movements.Position + +class SBlock(private val position: Position) : Block { + + override fun getNeededPositions(): Collection { + return listOf(Position(position.row + 0, position.column + 1), Position(position.row + 0, position.column + 2), Position(position.row + 1, position.column + 0), Position(position.row + 1, position.column + 1)) + } + + 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/implementation/SBlockTest.kt b/src/test/kotlin/blocks/implementation/SBlockTest.kt new file mode 100644 index 0000000..ef4e067 --- /dev/null +++ b/src/test/kotlin/blocks/implementation/SBlockTest.kt @@ -0,0 +1,36 @@ +package blocks.implementation + +import movements.Position +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class SBlockTest { + + @Test + fun `position 0,0 needed positions are (0,1), (0,2), (1,0), (1,1)`() { + val sBlock = SBlock(Position(0,0)) + assertEquals( + listOf(Position(0, 1), Position(0, 2), Position(1, 0), Position(1, 1)), + sBlock.getNeededPositions() + ) + } + + @Test + fun `position 0,1 needed positions are (0,2), (0,3), (1,1), (1,2)`() { + val sBlock = SBlock(Position(0,1)) + assertEquals( + listOf(Position(0, 2), Position(0, 3), Position(1, 1), Position(1, 2)), + sBlock.getNeededPositions() + ) + } + + @Test + fun `position 1,0 needed positions are (1,1), (1,2), (2,0), (2,1)`() { + val sBlock = SBlock(Position(1, 0)) + assertEquals( + listOf(Position(1, 1), Position(1, 2), Position(2, 0), Position(2, 1)), + sBlock.getNeededPositions() + ) + } + +} \ No newline at end of file