From 82589bb93e5b3d7a4c99394c1486c08e1d63eec4 Mon Sep 17 00:00:00 2001 From: mo Date: Tue, 18 Jun 2019 16:27:29 -0600 Subject: try to understand how this confusing, untestable api is supposed to work --- src/Q4/RandomSumGame.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/Q4/RandomSumGame.java') 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; + } } -- cgit v1.2.3