Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. public class PairOfDice
  2. {
  3. private final int Max = 6;
  4. private int FaceValue;
  5.  
  6. public PairOfDice()
  7. {
  8. FaceValue = 1;
  9. }
  10. public int roll()
  11. {
  12. FaceValue = (int)(Math.random()*Max)+1;
  13. return FaceValue;
  14. }
  15. public void setFaceValue(int value)
  16. {
  17. FaceValue = value;
  18. }
  19. public int getFaceValue()
  20. {
  21. return FaceValue;
  22. }
  23. public String toString()
  24. {
  25. String result = Integer.toString(FaceValue);
  26. return result;
  27. }
  28.  
  29. public static void main (String[] args)
  30. {
  31. PairOfDice die1 = new PairOfDice();
  32. PairOfDice die2 = new PairOfDice();
  33.  
  34. int SumOfRoles = die1.roll() + die2.roll();
  35.  
  36. System.out.println ("Die One: " + die1 + ", Die Two: " + die2);
  37. System.out.println ("Sum of results:" + SumOfRoles);
  38.  
  39. }
  40.  
  41. class RollingDice2
  42. {
  43. PairOfDice instantiate = new PairOfDice();
  44. int Value = instantiate.roll();
  45.  
  46.  
  47. }
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement