Die - return faceValue; }

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // Die.java Author: Lewis/Loftus // // Represents one die (singular of dice) with faces showing values // between 1 and 6. //******************************************************************** / public class Die { private final int MAX = 6; // maximum face value private int faceValue; // current value showing on the die //----------------------------------------------------------------- // Constructor: Sets the initial face value. //----------------------------------------------------------------- public Die() { faceValue = 1; } //----------------------------------------------------------------- // Rolls the die and returns the result. //----------------------------------------------------------------- public int roll() { faceValue = (int)(Math.random() * MAX) + 1;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return faceValue; } //-----------------------------------------------------------------// Face value mutator. //-----------------------------------------------------------------public void setFaceValue (int value) { faceValue = value; } //-----------------------------------------------------------------// Face value accessor. //-----------------------------------------------------------------public int getFaceValue() { return faceValue; } //-----------------------------------------------------------------// Returns a string representation of this die. //-----------------------------------------------------------------public String toString() { String result = Integer.toString(faceValue); return result; } }...
View Full Document

Ask a homework question - tutors are online