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