Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PairOfDice
- {
- private final int Max = 6;
- private int FaceValue;
- public PairOfDice()
- {
- FaceValue = 1;
- }
- public int roll()
- {
- FaceValue = (int)(Math.random()*Max)+1;
- return FaceValue;
- }
- public void setFaceValue(int value)
- {
- FaceValue = value;
- }
- public int getFaceValue()
- {
- return FaceValue;
- }
- public String toString()
- {
- String result = Integer.toString(FaceValue);
- return result;
- }
- public static void main (String[] args)
- {
- PairOfDice die1 = new PairOfDice();
- PairOfDice die2 = new PairOfDice();
- int SumOfRoles = die1.roll() + die2.roll();
- System.out.println ("Die One: " + die1 + ", Die Two: " + die2);
- System.out.println ("Sum of results:" + SumOfRoles);
- }
- class RollingDice2
- {
- PairOfDice instantiate = new PairOfDice();
- int Value = instantiate.roll();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement