
public class Dice {
	
	
	//constant for default number of sides
	//public: can be accessed outside of this class w/ 
	//  Dice.DEFAULT_SIDES
	//static: one value for the class (all the objects)
	//final: it can't be changed after it is set
	public static final int DEFAULT_SIDES = 6;
	
	//remember how many dice we created
	private static int NUM_DICE = 0;
	
	//data - what information is stored
	//  data fields / fields
	//  instance variables
	//  data member
	//  member variables
	
	// how many sides
	private int sides;
	
	// what is the current value (face up)
	private int currentValue;
	
	
	//methods - what actions can we take
	
	//constructor
	// called with new
	// name must be the same as the class
	// no return type (not void)
	
	//1 parameter - number of sides
	public Dice (int sides) {
		//initialize instance variables
		//this keyword refers to the current object
		//sides of this object v. the parameter sides
		//this.sides = sides;
		setSides(sides);  //use the method we wrote
		
		//this.currentValue = 1;
		roll();
		
		//update the number of dice
		NUM_DICE++;
	}
	
	//0 parameter constructor
	//create a 6-sided die
	public Dice () {
		//call the other constructor
		this(DEFAULT_SIDES);  //must be first code in the constructor
		//this.sides = 6;
		//this.currentValue = 1;
	}
	
	//roll the dice
	public int roll() {
		currentValue = (int)(Math.random()*sides) + 1;
		return currentValue;
	}
	
	
	//getters - accessors
	public int getCurrentValue() {
		return currentValue;
	}
	
	public int getSides() {
		return sides;
	}
	
	//setters - mutators
	public void setSides(int s) {
		if(s > 0) {
			sides = s;
		}
	}
	
	//turn the object into a String
	public String toString() {
		//create a String representation of this Dice object
		return String.format("%d-sided die (%d)", sides, currentValue);
	}
	
	//getter for the NUM_DICE static variable
	//should not depend on an object
	public static int getNumDice() {
		return NUM_DICE;
	}
	
}
