Pig - /* / Pig.java Author: Lewis and Loftus / / Solution...

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

View Full Document Right Arrow Icon
//******************************************************************** // Pig.java Author: Lewis and Loftus // // Solution to Programming Project 4.4 //******************************************************************** / class Pig { private int goal; private PairOfDice dice; private PigPlayer computer, human, currentPlayer; //----------------------------------------------------------------- // Sets up the game including the point goal for the game. //----------------------------------------------------------------- public Pig (int target) { goal = target; dice = new PairOfDice(); computer = new PigPlayer (20); human = new PigPlayer (PigPlayer.ASK); } //----------------------------------------------------------------- // This method contains the primary game loop, which terminates // only once a player has won the game. //----------------------------------------------------------------- public void play () { boolean noWinnerYet = true; currentPlayer = computer; do { takeTurn(); // Check for winner; otherwise switch players and continue
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Pig - /* / Pig.java Author: Lewis and Loftus / / Solution...

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

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