From 9eb006576d554968fb040755b9fb700edb75066d Mon Sep 17 00:00:00 2001 From: Marisa Pacitti Date: Thu, 29 Jan 2015 15:34:09 -0500 Subject: [PATCH] Debugger Lab chnages in bug and Answers. --- Answers.md | 30 ++++++++++++++++++++++++++++++ src/Die.java | 2 +- src/Main.java | 3 ++- src/PigGame.java | 2 +- src/ScoreSheet.java | 1 - 5 files changed, 34 insertions(+), 4 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..fd4b859 --- /dev/null +++ b/Answers.md @@ -0,0 +1,30 @@ +## Debugger Lab Answers +**Question 1** +cutoff is not a parameter to the method playTurn in the PigGame class because cutoff was +assigned as a parameter for all of the PigGame class, therefore you do not need cutoff in +the method playTurn because it is already assigned to the class. + +**Question 2** +The code would print the average number of turns the player had inorder to reach the goal +value of 100. However the code would turn the average as 0 because Scoresheet was just +reset. + +**Question 3** +The statement numBusts coula aslo be placed into the getNumTurns method because the method +is analyzing the turns and while it is analyzing it can also return the numBusts with out +affecting the results of the program. + +**Question 4** +I believe that the error in the code might be in the playTurn method, or playGame method. +I don't think that there could be problems in the code in the method PigGame. + +**Question 5** +There is something wrong with the dice because when I went through the debugger dice +rolled a 1 three times in a row. I found that thee was something wrong in the formatting +to roll the dice. With this change the program now returns the correct score, number of +turns, and turn average. + +**Question 6** +The average number of turns for the cutoff value of 10 is 6.25.The average number of turns +for the cutoff 15 is 7.6923076923076923. The average number of turns for the cutoff 20 is +6.666666666666667. The average number of turns for the cutoff 25 is 6.0588235294117645. diff --git a/src/Die.java b/src/Die.java old mode 100755 new mode 100644 index 6f3a8e4..9c024ea --- 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..576a495 --- a/src/Main.java +++ b/src/Main.java @@ -9,7 +9,8 @@ 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(); diff --git a/src/PigGame.java b/src/PigGame.java index 1081951..6002cd2 100644 --- a/src/PigGame.java +++ b/src/PigGame.java @@ -119,6 +119,6 @@ private int playTurn() } } - + diff --git a/src/ScoreSheet.java b/src/ScoreSheet.java index 0d3221f..52d8303 100644 --- a/src/ScoreSheet.java +++ b/src/ScoreSheet.java @@ -18,7 +18,6 @@ public ScoreSheet() score = 0; numTurns = 0; } - /** * Record the fact that one more turn has been completed * and add its score to the total