/* * @topic T00855 Using Comparable interface to sort objects * @brief DicePair class */ package hw7demo; public class DicePair { // data fields private Die dieOne; private Die dieTwo; // constructors: // construct dice with equal number of sides public DicePair(int dieSideCount) { dieOne = new Die( dieSideCount ); dieTwo = new Die( dieSideCount ); } // construct dice with unequal number of sides public DicePair(int numberOfSides, int numberOfSides2) { dieOne = new Die(numberOfSides); dieTwo = new Die(numberOfSides2); } // operations // generate new combination public int roll() { int total = dieOne.roll() + dieTwo.roll(); return total; } // obtain reference to a particular die object public Die getDieObject( int index ) { if ( index == 1 ) { return dieOne; } // TODO -- validate that index is 2. // If not valid -- report application logic error // and throw an exception. return dieTwo; } }//class DicePair