// hw8_2.cpp // program to create a craps game, using the Dice class #include using namespace std; #include "dice.h" enum Status { CONTINUE, WON, LOST }; int main() { Dice pair; int sum, myPoint; Status gameStatus; pair.init(); pair.roll(); cout << pair; sum = pair.sum(); switch ( sum ) { case 7: case 11: // win on first roll gameStatus = WON; break; case 2: case 3: case 12: // lose on first roll gameStatus = LOST; break; default: // remember point gameStatus = CONTINUE; myPoint = sum; cout << "Point is " << myPoint << endl; break; // optional } while ( gameStatus == CONTINUE ) { // keep rolling pair.roll(); cout << pair; sum = pair.sum(); if ( sum == myPoint ) // win by making point gameStatus = WON; else if ( sum == 7 ) // lose by rolling 7 gameStatus = LOST; } if ( gameStatus == WON ) cout << "Player wins" << endl; else cout << "Player loses" << endl; return 0; }