Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package unit5Classe;
- public class Craps {
- private Die die;
- private boolean playerWin;
- public Craps(Die d){
- die=d;
- playerWin=false;
- comeOut();
- }
- public void comeOut(){
- int roll=die.roll2Dice();
- if(roll==2||roll==12||roll==3){
- playerWin=false;
- }else if(roll==7||roll==11){
- playerWin=true;
- }else{
- rollOn(roll);
- }
- }
- public void rollOn(int point){
- //keep rolling until I roll the point or I roll 7
- //point wins, 7 loses
- int roll=die.roll2Dice();
- while(roll!=point&&roll!=7){
- roll=die.roll2Dice();
- }
- playerWin=roll==point;
- }
- }
Add Comment
Please, Sign In to add comment