/* Die3 class for rolling dice
 * Author: CPSC 111 Jan 2010 class
 * Date: Wed 27 Jan 2010
 *
 * When the die is rolled, it returns an integer between 1 and n with
 * random probability. 
 *
 * After our first pass, we refined our code. We saw that it was a
 * good idea to set backstop values in our constructor, so that we
 * could call roll() without having called setSides() first.
 *
 * We then specified which fields and methods were private versus
 * public. We saw how changing the name of a publicly accessible field
 * led to problems. 
 *
 * We tested this code with the RollDice and RollDice2 tester classes. 
 *
 */
import java.util.Random;

public class Die3 {

    // fields:
    private int howManySides;

    public Die3() {
	// use a backstop value
      	howManySides = 6;
    }

    public int roll()  {
	// declare Random variable
	Random numberGenerator = new Random(); // create Random object
        // want number between 1 and numSides
        // nextInt gives between 0 and k
	int randomNumber = numberGenerator.nextInt(howManySides) + 1; 
	return randomNumber;
    };

    public void setSides(int inputNumSides) {
	howManySides = inputNumSides;
    };

}

