-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(squareblock): implement initial positions
- Loading branch information
1 parent
1d8fcbe
commit 0bbcef9
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package blocks.implementation | ||
|
||
import blocks.Block | ||
import blocks.Rotation | ||
import movements.Direction | ||
import movements.Position | ||
|
||
class SquareBlock(private val initialPosition: Position) : Block { | ||
|
||
private val positions = listOf( | ||
Position(0, 0), Position(0, 1), Position(1, 0), Position(1, 1) | ||
) | ||
|
||
override fun getNeededPositions(): Collection<Position> { | ||
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") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package blocks.SquareBlock | ||
|
||
import blocks.implementation.SquareBlock | ||
import movements.Position | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
|
||
class SquareBlockTest { | ||
|
||
@Test | ||
fun `position 0,0 needed positions are (0,0), (0,1), (1,0), (1,1)`() { | ||
val squareBlock = SquareBlock(Position(0,0)) | ||
assertEquals( | ||
listOf(Position(0, 0), Position(0, 1), Position(1, 0), Position(1, 1)), | ||
squareBlock.getNeededPositions() | ||
) | ||
} | ||
|
||
@Test | ||
fun `position 0,1 needed positions are (0,2), (0,3), (1,1), (1,2)`() { | ||
val squareBlock = SquareBlock(Position(0,1)) | ||
assertEquals( | ||
listOf(Position(0, 1), Position(0, 2), Position(1, 1), Position(1, 2)), | ||
squareBlock.getNeededPositions() | ||
) | ||
} | ||
|
||
@Test | ||
fun `position 1,0 needed positions are (1,1), (1,2), (2,0), (2,1)`() { | ||
val squareBlock = SquareBlock(Position(1,0)) | ||
assertEquals( | ||
listOf(Position(1, 0), Position(1, 1), Position(2, 0), Position(2, 1)), | ||
squareBlock.getNeededPositions() | ||
) | ||
} | ||
} |