Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger Lab chnages in bug and Answers. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Answers.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion src/Die.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Die()
*/
public void roll()
{
upValue = ((int)Math.random() * 6) + 1;
upValue = (int) (Math.random() * 6) + 1;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Main.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/PigGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,6 @@ private int playTurn()
}
}




1 change: 0 additions & 1 deletion src/ScoreSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down