For thousands of years people have enjoyed playing dice games. Now you have the chance to make the computer into a champion dice player -- but be careful not to turn your computer player into a pig! The goal of this assignment is to get your feet wet in Java and to have fun. At the end, there will be an in-class tournament.
class Dice
{
public:
Dice(int sides); // constructor
int Roll(); // return the random roll
int NumSides(); // how many sides this die has
int NumRolls(); // # times this die rolled
private:
RandGen myGenerator; // random number generator
int myRollCount; // # times die rolled
int mySides; // # sides on die
};
Look at the Java class Math for details on how to make random
numbers.
You are to write a Java class that implements the Player interface given below.
interface PigPlayer { /** * return the name of your player * (either your name, login id, or make something up) */ public string getName ();/** * return the player's current score */ public int getScore ();/** * return the number of rounds player has played */ public int getNumRounds ();/** * play a round of the game pig using whatever strategy you want * @param difference difference between your score and the leading player */ public void playRound (int difference);/** * get the player ready to play a game * (reset score and number of rounds played to 0) */ public void reset (); }