/** A Dice (or Die) */

class Dice {



   private int top;    // top face

   private int sides;  // number of sides
   
   private int numRolled;

   

   /** A Dice has numSides sides and the top face is random */

   public Dice(int numSides) {

     sides = numSides;
     numRolled = 0;

     roll();

   }



   /** top gets a random value in 1..sides */

   public void roll() {

     setTop(randInt(1,getSides())) ;
     numRolled++;
   }

   

   /** = random int in low..high */

   public static int randInt(int low, int high) {

     return (int) (Math.random()*(high-low+1))+low;

   }



   /** = Get top face */

   public int getTop() { return top; }

 

   /** = Get number of sides */

   public int getSides() { return sides; }  

   

   /** Set top to faceValue  */

   public void setTop(int faceValue) { top= faceValue; }

   public int getNumRolled() { return numRolled; }
   

   /** = String description of this Dice */

   public String toString() {

     return  getSides() + "-sided dice shows face " + getTop();

   }

}

