We want to create a small game. The game consists of a player trying to guess a random number. The player will have three attempts to guess the number. If the number is correctly guessed, then the player wins, if not, the player loses.
If the player fails to guess the number, the game must notify the user if the number it's higher or lower.
This kata is meant to work on test doubles. But it can also be solved without them. Also, it's an excellent kata to work on Primitive obsession and baby steps.
As player
I play the number 5
the player wins
Initial state | Player wins on the first move |
As player
I play a 10
I play a 3
I play a 5
the player wins
Initial state | Player first move | Player second move | Player third move |
As player
I play a 10
I play a 3
I play a 5
the player loses
Initial state | Player first move | Player second move | Player third move |
public class GuessingNumberGame {
GuessingNumberGame(RandomNumberGenerator generator){}
public String guessNumber(int guessedNumber) {}
}