public class Dice { // The data member dice is a reference variable that // can point to an array of Die objects. private Die[] dice; public Dice (int numDice) { dice = new Die[numDice]; for (int i=0; i= dice.length || position < 0) { // position is invalid, return null return null; } // position is valid, return the appropriate Die object return dice[position]; } /******************************************* * getNumDice * * - Takes no parameters * - Returns the length of the dice array *******************************************/ public int getNumDice() { // The data member dice is private, so classes outside // of Dice cannot directly access dice, which also means // that they cannot directly access dice.length. return dice.length; } /******************************************* * toString * * - Takes no parameters * - Returns a String containing the face values * of all of the Die objects in the array *******************************************/ public String toString() { // Create a blank String variable String diceString = ""; // For each element in the dice array, add its // face value (obtained through dice[i].getFace()) // to the String. Separate each element's face // by the tab character. for (int i=0; i