

/**
 * This class models a simple die object, which can have any number of sides.
 *   @author Dave Reed
 *   @version 8/25/08
 */
public class Die {
  private int numSides;
  private int numRolls;

  /**
   * Constructs a 6-sided die object
   */
  public Die() {
      this.numSides = 6;
      this.numRolls = 0;
  }

  /**
   * Constructs an arbitrary die object.
   *   @param sides the number of sides on the die
   */
  public Die(int sides) {
      this.numSides = sides;
      this.numRolls = 0;
  }

/**
   * Gets the number of sides on the die object.
   *   @return  the number of sides (an N-sided die can roll 1 through N)
   */
  public int getNumberOfSides() {
      return this.numSides;
  }
	
  /**
   * Gets the number of rolls by on the die object.
   *   @return  the number of times roll has been called
   */
  public int getNumberOfRolls() {
      return this.numRolls;
  }
		
  /**
   * Simulates a random roll of the die.
   *   @return  the value of the roll (for an N-sided die, 
   *            the roll is between 1 and N)
   */
  public int roll() {
      this.numRolls++;
      return (int)(Math.random()*this.getNumberOfSides() + 1);
  }
}
