Create a constructor. It should take in three arguments (in this order): an array of
Player
s, a
Die
, and an
int
representing the victory score.
The constructor should store all of these in
private fields.
4.
Create a method called
play()
. It takes no arguments.
(a)
Do the following
forever
(yes, really.
We’ll use a
return
statement to end the method
when the game is over).
i.
Loop
over
the
array
of
players.
For
each
player,
do
the
following:
(you
probably
want to do a
for
loop over the array of players)
public class Game {
private Player[] players;
private Die die;
private int victoryScore;
public Game(Player[] players, Die die, int victoryScore) {
this.players = players;
this.die = die;
this.victoryScore = victoryScore;
}
public void play() {
while (true) {
for (Player player : players) {
}
}
}
}
Comments
Leave a comment