Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Player {
  4. private static Random rnd = new Random(); // Same random for all objects
  5. private int money;
  6. private int die1;
  7. private int die2;
  8.  
  9. public Player() {
  10. money = 100;
  11. }
  12.  
  13. public void roll() {
  14. die1 = rnd.nextInt(6) + 1;
  15. die2 = rnd.nextInt(6) + 1;
  16. }
  17.  
  18. public int total() {
  19. return die1 + die2;
  20. }
  21.  
  22. public int getMoney() {
  23. return money;
  24. }
  25.  
  26. public void setMoney(int money) {
  27. this.money = money;
  28. }
  29.  
  30. public int getDie1() {
  31. return die1;
  32. }
  33.  
  34. public int getDie2() {
  35. return die2;
  36. }
  37.  
  38. public static Random getRnd() {
  39. return rnd;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement