PlayDice - // System.out.println(sum); if ((sum == 7)||(sum...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class PlayDice { Dice a , b; //typeOfWin: 0 for win on 1st, 1 for craps,2 for win with points, 3 for lose with points; public PlayDice(){ a = new Dice(); b = new Dice(); } public int throwDice(){ return a.throwIt() + b.throwIt(); } public int play(){ int sum; int points; boolean flag = true; sum = throwDice();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // System.out.println(sum); if ((sum == 7)||(sum == 11)) return 0; else if ((sum == 2)||(sum==3)||(sum==12)) return 1; else points =sum; do { sum = throwDice(); // System.out.println(sum); if (sum == 7) return 3; else if (sum == points) flag = false; }while (flag); return 2; } }...
View Full Document

This note was uploaded on 03/22/2012 for the course CS 55 taught by Professor Vagada during the Spring '10 term at Santa Monica.

Ask a homework question - tutors are online