public class Dice {
  
  // Private data
  private int mySides;
  private int myLastRoll;
  
  // construct and initialize the data
  public Dice (int sides) {
    mySides = sides;
    myLastRoll = 1;
  }
  
  // accessor methods - These methods will not change the values of the private data
  // return the number of sides of the Dice
  public int getSides() {
    return mySides;
  }
  
  // return the value of the last roll
  public int getLastRoll() {
    return myLastRoll;
  }
  
  public String toString() {
    return "sides: " + mySides + "     Last Roll: " + myLastRoll;
  }
  
  // modifier method - This method will change the value(s) of the private data
  // Rolls the Dice and returns this value
  public int roll() {
    myLastRoll = (int)(Math.random() * mySides) + 1;
    return myLastRoll;
  }
}
