From c2493742096b0e286e96c061c7d71cb48f941a69 Mon Sep 17 00:00:00 2001 From: Emily Mudd Date: Thu, 29 Jan 2015 15:39:08 -0500 Subject: [PATCH] Debugger Lab: fixed bug and added Answers --- Answers.md | 36 ++++++++++++++++++++++++++++++++++++ src/Die.java | 2 +- src/Main.java | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 Answers.md mode change 100755 => 100644 src/Die.java mode change 100755 => 100644 src/Main.java diff --git a/Answers.md b/Answers.md new file mode 100644 index 0000000..63d3851 --- /dev/null +++ b/Answers.md @@ -0,0 +1,36 @@ +### Answers to Debugger Lab + +**Question 1:** `Cutoff` is not a parameter because it is assigned as a +parameter in the `PigGame` class, so it is not needed in `playTurn` method. + +**Question 2:** This line of code would print the average number of turns it +took to reach the goal value, which in this case is 100, however because of +its location in the code it would return 0 because the score was just reset. + +**Question 3:** `numBusts` could be moved to `numTurns` because it would tell +you how many of the turns that were taken were a bust. + +**Question 4:** There could be a problem in when to start a new score sheet/new +game so in the `playGame` method. The `PigGame`appears to be sound at the moment. + +**Question 5:** +Keeps running in scoreSheet and reseting to 0 every time the +`pigGame` method is called, so it is not keeping track of the score after each +turn. + +Something appears to be wrong with the die because it busts every time. If this +is happening + +One problem found was a formatting error in the Die.java +`upValue = (int) (Math.random() * 6) + 1;` + +With change we get the correct values returned for the original cutoff of 18. +102 +13 +7.85 +**Question 6:** +Cutoff Value Average Number of Turns +10 6.0 +15 8.5 +20 10.02, ran another time and got 7.36 +25 16.83, ran a couple more times and got 7.21,12.75, 10.1, 7.21 \ No newline at end of file diff --git a/src/Die.java b/src/Die.java old mode 100755 new mode 100644 index 6f3a8e4..ab3e8fc --- a/src/Die.java +++ b/src/Die.java @@ -22,7 +22,7 @@ public Die() */ public void roll() { - upValue = ((int)Math.random() * 6) + 1; + upValue = (int) (Math.random() * 6) + 1; } /** diff --git a/src/Main.java b/src/Main.java old mode 100755 new mode 100644 index ff2edf8..306a767 --- a/src/Main.java +++ b/src/Main.java @@ -9,7 +9,7 @@ public class Main public static void main(String[] args) { // Create a new game with a cutoff of 18 - PigGame g = new PigGame(18); + PigGame g = new PigGame(25); // Run one game g.playGame();