Sunteți pe pagina 1din 1

JAVA PROGRAMMING ASSIGNMENT

Problem Description
Part 1
Create a COMMAND LINE based application to play a game called Perfect Hundred.
In this game, the user/player competes 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 your opponent does. If, on any turn, the player rolls a 1, all points
accumulated for that round are forfeited and control of the dice moves to the other
player. If the player rolls two1s in one turn, the player loses all points accumulated
thus far in the game and loses control of the dice. The player may voluntarily turn
over the dice after each roll. Therefore the player must decide to either roll again
and risk losing points or relinquish control of the dice, possibly allowing the other
player to win. Implement the computer player such that it always relinquishes the
dice after accumulating 20 or more points in any given round.
Note that if at any round, should current points rolled added to the accumulated
points exceed 100, then the current points rolled will not be added and player needs
to relinquish control of the dice.
You may use some of the methods defined in the Die class of Chapter 5 in the
textbook to help in your assignment.
Minimally, you are to create four classes, class Die, class PairOfDice, class Player
and class TestGame.
class Die has the ability to roll the die and produce a new random face value.
class PairOfDice should compose of two Die objects. Include methods to set and get
the individual die values, a method to roll the dice, and a method that returns the
current sum of the two die values.
class Player has an instance of class PairOfDice and also to decide to continue
playing the game or relinquish control of the dice.
class TestGame creates two instances of class Player, an instance of PairOfDice and
it plays the game. In addition, it also reports who the winner is.
Part 2
You need two other classes, class DisplayGamePanel and class GamePanel to create
a GUI by allowing 2 players to play the Perfect Hundred game. Each player is able to
roll a pair of dice and the game is over when one of the players has accumulated
100 points; report who the winner is and the total number of rolls taken to win the
game. You may consider having a New Game button to play another game.

S-ar putea să vă placă și