diff --git a/src/main/kotlin/rps/App.kt b/src/main/kotlin/rps/App.kt deleted file mode 100644 index ce187fa..0000000 --- a/src/main/kotlin/rps/App.kt +++ /dev/null @@ -1,5 +0,0 @@ -package rps - -fun main() { - println("Hello, world") -} diff --git a/src/main/kotlin/rps/Game.kt b/src/main/kotlin/rps/Game.kt new file mode 100644 index 0000000..2606fe5 --- /dev/null +++ b/src/main/kotlin/rps/Game.kt @@ -0,0 +1,22 @@ +package rps + +fun main() { + println("Hello, world") +} + +/** A possible move in a game of rock-paper-scissors. */ +enum class Move { + ROCK, + PAPER, + SCISSORS +} + +// purposely not calling this Result to avoid confusion with kotlin.Result and similar +enum class Outcome { + WIN, + DRAW, + LOSS +} + +/** Determine the [Outcome] of [first] vs [second] from the perspective of [first]. */ +fun determineOutcome(first: Move, second: Move): Outcome = TODO() \ No newline at end of file diff --git a/src/test/kotlin/rps/AppTest.kt b/src/test/kotlin/rps/AppTest.kt deleted file mode 100644 index be22bdf..0000000 --- a/src/test/kotlin/rps/AppTest.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This Kotlin source file was generated by the Gradle 'init' task. - */ -package rps - -import kotlin.test.Test -import kotlin.test.assertEquals - -class GameTest { - @Test - fun testAppHasAGreeting() { - assertEquals(2 + 2, 4) - } -} diff --git a/src/test/kotlin/rps/GameTest.kt b/src/test/kotlin/rps/GameTest.kt new file mode 100644 index 0000000..34ebe0e --- /dev/null +++ b/src/test/kotlin/rps/GameTest.kt @@ -0,0 +1,21 @@ +package rps + +import rps.Move.* +import rps.Outcome.* +import kotlin.test.Test +import kotlin.test.assertEquals + +class GameTest { + @Test + fun testOutcomeCalculation() { + val games = listOf( + Triple(PAPER, ROCK, WIN), + Triple(ROCK, PAPER, LOSS), + Triple(PAPER, SCISSORS, LOSS), + Triple(ROCK, ROCK, DRAW), + ) + for ((first, second, expected) in games) { + assertEquals(determineOutcome(first, second), expected) + } + } +}