ITEC 120 Back to Assignment index page
   
Assignment 2 - Pig - due at midnight on Mon, Oct 24 - submit to RU05 folder

Description: 

Design and write a class called PairOfDice, which has 2 six sided dice.

PairOfDice

- face1 : int
- face2 : int

+ PairOfDice()
+ roll() : void
+ points() : int
+ one() : boolean
+ pairOfOnes() : boolean

+ toString() : String

Write a driver to play a game called Pig. Let the user play against the computer. On each turn, the current player rolls a pair of dice and accumulates points. The goal is to reach 100 points before the other player. If, on any turn, the player rolls a 1 (one of the dice shows a 1), all points accumulated for that turn are forfeited and control of the dice goes to the other player. If a player rolls double 1s, the player loses all points accumulated so far in the game and control of the dice goes to the other player.

A player may voluntarily give up control of the dice after each roll. So, a player must decide to roll again (be a pig) and risk losing points, or, play it safe, keep accumulated points, and give up control of the dice to the other player, who may win.

Implement the computer player such that it always gives up control of the dice after accumulating 20 or more points on a given round.

Submit your finished java files (2 of them) to the RU05 folder in your folder on neelix.