/* * @topic T00825 Dice Roller App Sample * @brief Die class */ package diceroll; public class Die { static final int DEFAULT_SIDE_COUNT = 6; private int dieSideCount; private int faceValue; // constructors public Die() { dieSideCount = DEFAULT_SIDE_COUNT; roll(); // immediately roll } public Die( int dieSideCount ) { this.dieSideCount = dieSideCount; roll(); // immediately roll } // the user wants to set the face value public Die( int dieSideCount, int faceValue ) { this.dieSideCount = dieSideCount; // TODO -- verify that the faceValue is valid this.faceValue = faceValue; } public int roll() { faceValue = 1 + (int) ( Math.random() * dieSideCount ); return faceValue; } }//class Die