Files Classes Functions Hierarchy
00001 00002 #include <iostream> 00003 using namespace std; 00004 00005 #include <textGame.h> 00006 00007 00008 void textGame::printGameState() 00009 { 00010 hand & dh(pg.deal->hnd); 00011 hand & ph(pg.player); 00012 cout << "D: " << dh.calculate() << " "; 00013 if (dh.hasAce) 00014 cout << "hasAce"; 00015 cout << endl; 00016 cout << "P: " << ph.calculate() << " "; 00017 if (ph.hasAce) 00018 cout << "hasAce"; 00019 cout << endl; 00020 } 00021 00022 00023 textGame::textGame() 00024 { 00025 char ch; 00026 for (;;) 00027 { 00028 printMenu(); 00029 00030 cin >> ch; 00031 if (ch=='q') 00032 return; 00033 00034 if (pg.alive) 00035 { 00036 switch (ch) 00037 { 00038 case '1': pg.alive_hold(); break; 00039 case '2': pg.alive_play(); break; 00040 case '3': pg.alive_doubleAndPlay(); break; 00041 } 00042 } 00043 else 00044 { 00045 switch (ch) 00046 { 00047 case '1': pg.notalive_dealCards(); break; 00048 case '2': 00049 cout << "dealerWins=" << pg.dealerWins << " "; 00050 cout << "playerWins=" << pg.playerWins << endl; 00051 continue; 00052 case '3': return; 00053 } 00054 } 00055 00056 printGameState(); 00057 } 00058 00059 } 00060 00061 void textGame::printMenu() 00062 { 00063 if (pg.alive) 00064 print_alive(); 00065 else 00066 print_notalive(); 00067 } 00068 00069 void textGame::print_alive() 00070 { 00071 cout << "1. Hold" << endl; 00072 cout << "2. Play" << endl; 00073 cout << "3. Double and Play" << endl; 00074 } 00075 00076 00077 void textGame::print_notalive() 00078 { 00079 cout << "1. Deal the Cards" << endl; 00080 cout << "2. Print Score" << endl; 00081 cout << "3. Quit" << endl; 00082 } 00083 00084 00085 00086
1.5.8