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

The bug has been Debugged! #7

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
35 changes: 35 additions & 0 deletions src/Answers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# CSCI 121: Debugger Lab Answers

#### Name: Marlon Moraga
##### Date: 1/29/15








## Question 1:

The reason why the cutoff is not a parameter to the method of playturn in the PigGame class because cutoff is a contructor.It's receiving information to create the die or the game.


## Question 2:

The following code thats going to print is 0

## Question 3:

In the the pigGame class, I would move numBusts in Playturn under the while loop and in the if statement because the score will be always be 0 and numBusts will add +1 which wont affect the code at all.

## Question 4:

Based on my understanding, the problem would be located in the die.java class because I notice that the math in one of the code inside this class is causing an ifinite loop.

## Question 5:
The problem with the program was that the casting method was only only casting math.random which causes an infinite loop of 1. For example, the code ((int)Math.Random()*6)+1 was giving major problems. In addition, the int which is a casting method was only casting Math.Random giving the results of always being 1. I changed this by adding another parathese to the whole code. For example, (int)((Math.random() *6)+1).

## Question 6:
For the number 10: 100, 14,~7.1425.
For the number 15: 104, 15, ~6.93334. For the number 20: 103, 12, ~8.58334. For the number 25: 101 ,9, ~11.22221
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
2 changes: 1 addition & 1 deletion src/Main.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down