LCR (http://en.wikipedia.org/wiki/LCR_(dice_game)) is a dice game for 3 players. Each player receives 3 chips to start with. The game is played with three six-sided dice marked with the following symbols:
“L”, “C”, “R”, “.”, “.”, and “.”
Gameplay:
The game ends when only one player still has chips left. That player wins the game.
Players cannot be eliminated from the game: a player has 0 chips rolls 0 dice, but they can still receive chips from the other players.
The goal of this lab session is to write a command-line based version of the LCR game.
CommandLineLCR
in the code template). One of these classes is LCRGame
, representing one complete game of LCR. What other classes do you need?
toString()
method so it prints a simple representation of the object.
CommandLineLCR
called testXXX()
where XXX
is the name of the class you just implemented. In this method, create at least one new object of the class, call each method at least once, and compare the results with the expected results. Call this method from the main
method of CommandLineLCR
.
LCRGame
class by using the other classes you implemented.
buildLCRGame
method in CommandLineLCR
, create a new object of class LCRGame
and return it.
render
method in CommandLineLCR
, print out a representation of the current game state. This should include the number of chips owned by each player and the most recent result of each die.
runCommandLineLCR
method in CommandLineLCR
by uncommenting all the code and filling in the blanks.
TIP Some ideas for possible methods:
getPlayerRight
, return the player to the right of the current player.getPlayerLeft
, return the player to the left of the current player.getNbRolls
, return how many dice should be rolled by the current player.Think about which class they belong to. Sometimes there are multiple possible answers.
LCR started
Players: Alice (3 chips) Bob (3 chips) Cedric (3 chips)
Current player is Alice (3 chips)
> r
R . .
Players: Alice (2 chips) Bob (4 chips) Cedric (3 chips)
Current player is Bob (4 chips)
> r
C R C
Players: Alice (2 chips) Bob (1 chips) Cedric (4 chips)
Current player is Cedric (4 chips)
> r
R L .
Players: Alice (3 chips) Bob (2 chips) Cedric (2 chips)
Current player is Alice (3 chips)
> r
. . .
Players: Alice (3 chips) Bob (2 chips) Cedric (2 chips)
Current player is Bob (2 chips)
> r
R .
Players: Alice (3 chips) Bob (1 chips) Cedric (3 chips)
Current player is Cedric (3 chips)
> r
. . C
Players: Alice (3 chips) Bob (1 chips) Cedric (2 chips)
Current player is Alice (3 chips)
> r
C . .
Players: Alice (2 chips) Bob (1 chips) Cedric (2 chips)
Current player is Bob (1 chips)
> r
C
Players: Alice (2 chips) Bob (0 chips) Cedric (2 chips)
Current player is Cedric (2 chips)
> r
. .
Players: Alice (2 chips) Bob (0 chips) Cedric (2 chips)
Current player is Alice (2 chips)
> r
. C
Players: Alice (1 chips) Bob (0 chips) Cedric (2 chips)
Current player is Bob (0 chips)
> r
Players: Alice (1 chips) Bob (0 chips) Cedric (2 chips)
Current player is Cedric (2 chips)
> r
C .
Players: Alice (1 chips) Bob (0 chips) Cedric (1 chips)
Current player is Alice (1 chips)
> r
L
Players: Alice (0 chips) Bob (0 chips) Cedric (2 chips)
Game over! Winner is Cedric (2 chips)