code - public static void main(String args) { new...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
public static void main(String[] args) { new Yahtzee().start(args); } public void run() { IODialog dialog = getDialog(); nPlayers = dialog.readInt("Enter number of players"); playerNames = new String[nPlayers ]; for (int i = 1; i <= nPlayers ; i++) { playerNames[i - 1] = dialog.readLine("Enter name for player " + i); } display = new YahtzeeDisplay(getGCanvas(), playerNames); playGame(); } private void playGame() { boolean[] diceKept = new boolean[N_DICE]; for (int i=1; i<= nPlayers ; i++) { diceKept = resetArray(diceKept); display.printMessage(playerNames[i-1]+", it is your turn. Please click to roll the dice." ); display.waitForPlayerToClickRoll(i); for (int roll=1; roll<3; roll++) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
diceTops = makeRandomRoll(diceTops, diceKept); display.displayDice(diceTops); display.printMessage("Choose the dice you want to reroll, and then roll again." ); display.waitForPlayerToSelectDice(); diceKept = checkForRerolledDice(); } display.displayDice(diceTops); display.printMessage("Please select what category you want to
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

code - public static void main(String args) { new...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online