Description
Your client is developing a new Java class library to support group games. As lead developer, you have been tasked to design and implement one of the most fundamental classes in this library: Die (singular of Dice). Typically, the Dice we are familiar with is a cube with the values 1 through 6 on different faces. When rolled, the Die lands randomly showing one of the faces up, i.e. its “value”. Your client wants a more general Die that can represent a shape with any number of sides (> 1). Further, a Die can be “frozen” which will prevent its value from changing, even if someone tries to set its value or roll it.
In addition to writing the Class Die, you will need to write a test driver program to prove that the Die Class operates correctly. See the Required Test cases below, and the sample output.
2. Class Definition
Constructors (all public)
Die(int numSides): Creates a new, unfrozen Die with the given number of sides and initial value of 1. Ensure that the number of sides > 1. If not, print a message and assume 6 sides.
Die(): Creates a new Die with 6 sides by using the constructor above.
Accessors/Mutators public void setValue(int v): Set the value of the Die, if the status is not frozen. If the Die is frozen, ignore this request, without a message. Ensure that the value is compatible with the number of sides (0 < v <= numSides). If not, print a message and set the value to 1.
public int getValue(): Return the value of the Die.
Functions public void roll(): “Roll the Die” and set the value to the resulting value. If the Die is frozen, ignore this request, without a message. The resulting value should be between 1 and number of Sides, inclusive.
public void print(): Print a simple graphic for the Die: “[n:x]”, where n is the value, x is the number of sides.
public void draw(): If the number of sides <= 6, print a more realistic graphic for the Die. If the number of sides > 6, default to print(). The example for 5 is shown below:
…….
. .
. * * .
. * .
. * * .
. .
…….
public void freeze(): Set the status of the die so that it will not change value (Set setValue and roll).
public void unfreeze(): Set the status of the die so that it is allowed to change value (See setValue and roll).







