Skip to main content

Need help with "Pig" dice game program...resetting score to 0 when a 1 is rolled

1 reply [Last post]
Joined: 2012-04-05

Okay so I'm in an intro to Java course, and our teacher has given us some code for a dice game called Pig. The point of the game is to roll 2 die during a turn, and then add the score to your total. If you roll a 1, your turn ends, and all points that turn are forfeited. If you roll double 1's during your turn, all your TOTAL points are forfeited. You can keep rolling and risk losing your points due to a 1, or you can hand the dice over to the computer and keep the points you've earned thusfar. The first person to 100 wins. The code works, but I have to find a way to reset the turnTotal to 0 if a 1 is rolled, and find away to reset total points to 0 if double 1's are rolled. I am completely stumped, and would LOVE some help. It's probably an easy fix, but due to my inexperience I can't seem to figure it out. Here's links to my code:

Die class:
PairOfDice class:
RollingDice class:
DiceGame class:

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2012-04-18

Post the code here (rather than providing links to ???) and I'll have a look at it.