Advertisement
mmayoub

Die.java

Jan 28th, 2023
848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.26 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Die {
  4.     private int top;
  5.     private Random rnd;
  6.  
  7.     public Die() {
  8.         rnd = new Random();
  9.         top = 1 + rnd.nextInt(6);
  10.     }
  11.  
  12.     public void roll() {
  13.         top = 1 + rnd.nextInt(6);
  14.     }
  15.  
  16.     public int getNum() {
  17.         return top;
  18.     }
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement