#include #include using namespace std; // Exceptions class RuntimeException { private: string errorMsg; public: RuntimeException(const string& err) { errorMsg = err; } string getMessage() const { return errorMsg; } }; class IndexOutOfBounds: public RuntimeException { public: IndexOutOfBounds(const string& err = "Index out of bounds!"): RuntimeException(err) {} }; // Class of game entry class GameEntry { // Stores the game scores public: GameEntry(const string& n="", int s=0); // Constructor string getName() const; // Get player name int getScore() const; // Get player score private: string name; // Player's name int score; // Player's score }; GameEntry::GameEntry(const string& n, int s): name(n), score(s) {} string GameEntry::getName() const { return name; } int GameEntry::getScore() const { return score; } // Class of scores class Scores { public: Scores(int maxEnt=10); // Constructor ~Scores(){}; // Destructor void add (const GameEntry& e); // add an entry GameEntry remove(int i) throw (IndexOutOfBounds); // Remove a single entry void print(); // For printing the scores private: int maxEntries; // maximum number of entries int numEntries; // actual number of entries vector entries; // array of game entries }; Scores::Scores(int maxEnt) { // Constructor maxEntries = maxEnt; entries = vector(maxEnt); numEntries = 0; } void Scores::print() { cout << "numEntries=" << numEntries << ", maxEntries=" << maxEntries << endl; for (int i=0; i