micher43

E8.14

Nov 20th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.25 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Die {
  4.    
  5.    
  6.     private static Random generator;
  7.     private int sides;
  8.    
  9.     public Die(int s){
  10.     sides = s;
  11.     generator = new Random();
  12.    
  13.     }
  14.    
  15.     public int cast(){
  16.        
  17.     return 1+ generator.nextInt(sides);
  18.    
  19.     }
  20.        
  21. }
Advertisement
Add Comment
Please, Sign In to add comment