From 2cf0e084af14cb863dc3bfacdd6a0e26d9072efc Mon Sep 17 00:00:00 2001 From: Concepcion Sosa Date: Thu, 29 Jan 2015 15:42:57 -0500 Subject: [PATCH 1/3] Changes in Die class. Under upValue --- src/Die.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 src/Die.java diff --git a/src/Die.java b/src/Die.java old mode 100755 new mode 100644 index 6f3a8e4..25645ba --- 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); } /** From 1f1ec621d4491fa385bcda9e1e416f6417e00493 Mon Sep 17 00:00:00 2001 From: Concepcion Sosa Date: Thu, 29 Jan 2015 15:49:02 -0500 Subject: [PATCH 2/3] Added java files changes --- src/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 src/Main.java 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(); From 060f28c3c3460500b5b97484eb2cd87a6e0a0336 Mon Sep 17 00:00:00 2001 From: Concepcion Sosa Date: Thu, 29 Jan 2015 15:51:37 -0500 Subject: [PATCH 3/3] added answer file --- debugger_lab_answers.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 debugger_lab_answers.md diff --git a/debugger_lab_answers.md b/debugger_lab_answers.md new file mode 100644 index 0000000..a732c59 --- /dev/null +++ b/debugger_lab_answers.md @@ -0,0 +1,22 @@ +## Debugger Lab Answers +###Date:1/29/15 +Concepcion Sosa + +**Question 1:** +The reason why `cutoff` is not a parameter to the method `playTurn` in the `PigGame` class is because `cutoff` is the constructor. + +**Question 2:** +The following code would print out 0.0. + +**Question 3:** +This statement can be moved to the playTurn method. In the playTurn method, the statement would go within the` if` statement that is within the `while` statement. + +**Question 4:** +Based on my current understanding, I think that the problem(s) might be located in the Die class. i think everything else should be normal and run properly. + +**Question 5:** +The problem was within the Die class. Under the `public void roll()`, the upValue was `((int)Math.random()*6)+1` which was causing a problem. It would change the number into an integer. However, using the random function, the number it gives us is between 0 & 1. So changing that decimal into an integer would not be helpful because it rounds down. (Random function gives me .09, changes it into an integer which would be 0 +1, which would always be 1.) Solution, I decided to re-write it as `(int)((Math.random() * 6) + 1)`, which allows the math random function to be multiplied by 6 and added together with 1, which then finally gets changed into an integer. + +**Question 6:** +For the number 10: 100, 14, ~7.1425. +For the number 15: 104, 15, ~6.933334. For the number 20: 103, 12, ~8.583334. For the number 25: 101, 9, ~11.22221.