CS1 Standard Demo Page

The following text was written to the standard output stream when the Die.java program was executed from Netbeans.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package chance;

/**
 *
 * @author ecuevas
 */
public class Die {
    //THE INSTANCE VARIABLES (STATE)
    
    private int order;
    private int top;
    
    //THE CONSTRUCTORS
    public Die() { 
        order = 6;
        top = (int) ((Math.random() * 6) + 1);
        
    }
    
    public Die(int nrOfSides) {
        order = nrOfSides;
        top = (int) ((Math.random() * 6 ) + 1);
        
    }
    
    // THE METHODS (BEHAVIOR)
    public int top() {
        return top;
    }
    
    public void roll() {
        top = (int) ((Math.random() * order)+1);
    }
}