diff options
| author | mo <mo.khan@gmail.com> | 2019-06-18 16:27:29 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2019-06-18 16:27:29 -0600 |
| commit | 82589bb93e5b3d7a4c99394c1486c08e1d63eec4 (patch) | |
| tree | dbc111cd4c92eace419b9e98d58c860d1b30d005 /src/Q4/RandomSumGame.java | |
| parent | 717a1964133f05eb9d39e879f2ed27ebb054cdb2 (diff) | |
try to understand how this confusing, untestable api is supposed to work
Diffstat (limited to 'src/Q4/RandomSumGame.java')
| -rw-r--r-- | src/Q4/RandomSumGame.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/Q4/RandomSumGame.java b/src/Q4/RandomSumGame.java index 823c32e..e5b6ce0 100644 --- a/src/Q4/RandomSumGame.java +++ b/src/Q4/RandomSumGame.java @@ -1,5 +1,7 @@ package Q4; +import java.util.*; + public class RandomSumGame { private boolean start; private int d1; @@ -8,7 +10,19 @@ public class RandomSumGame { private int valuePoint; private String status; - public void play(int d1, int d2) { } - public void play() { } - public void rollDice() {} + public void play(int d1, int d2) {} + + public void play() { + this.rollDice(); + this.play(this.d1, this.d2); + } + + public void rollDice() { + this.d1 = this.roll(); + this.d2 = this.roll(); + } + + private int roll() { + return new Random().nextInt(5) + 1; + } } |
