// Game.cc // Implements class Game #include #include "Game.h" Game::Game() { for (int i=0; i<5;i++) dice[i] = new Die(); } void Game::play_turn() { int selection, dice_vals[5], i; bool flag, valid_option; cout << endl << "Turn " << turn << ": " ; for (i=0;i<5;i++) { dice[i]->roll(); dice_vals[i] = dice[i]->get_face(); cout << dice_vals[i] << " "; } do { flag = false; cout << endl << endl << "Enter selection (1-13): "; cin >> selection; valid_option = card->check_valid_option(selection); if (!valid_option || selection<1 || selection>13) { cout << endl << " Invalid selection! - try again" << endl << endl; flag = true; } } while (flag); card->select_scoring_option(dice_vals,Scoring_option(selection)); turn++; } void Game::play() { turn = 1; card = new Scoresheet(); card->display(); while ( turn<=13 ) play_turn(); cout << endl << endl << "Game over!!" << endl << endl; cout << "Final score: " << card->get_total_score() << endl << endl; delete card; } Game::~Game() { for (int i=0;i<5;i++) delete dice[i]; }