import java.util.Random;

public class Dice {
  private int mySides, myLastRoll;
  private Random myRandomObject;
  
  // Constructor
  public Dice (int sides) {
    mySides = sides;
    myLastRoll = 0;
    myRandomObject = new Random();
  }
  
  // accessors
  // Returns the number of sides on the die
  public int getSides() { return mySides; }
  
  // Returns the value of the last roll
  public int getLastRoll() { return myLastRoll; }
  
  // Outputs the state of the die
  public String toString() { 
    return "a Dice object with mySides " + mySides
      + ", and myLastRoll " + myLastRoll;
  }
  
  // modifier
  // Finds and returns the value of the last roll
  public int roll() { 
    myLastRoll = 1 + myRandomObject.nextInt( mySides );
    return myLastRoll;
  }
  
  
  
}
