/home/ssingh6/NetBeansProjects/CS1/src/chance/Die.java |
1 /* 2 * To change this license header, choose License Headers in Project Properties. 3 * To change this template file, choose Tools | Templates 4 * and open the template in the editor. 5 */ 6 package chance; 7 8 /** 9 * 10 * @author ssingh6 11 */ 12 public class Die { 13 private int order; 14 private int top; 15 16 public Die() 17 { 18 order=6; 19 top=(int) ((Math.random()*6)+1); 20 21 } 22 public Die (int nrOfSides) 23 { 24 order= nrOfSides; 25 top= (int) ((Math.random()*nrOfSides) +1); 26 } 27 public int top() 28 { 29 return top; 30 } 31 public void roll () { 32 top= (int) ((Math.random()*order) +1); 33 } 34 }