Question: In C++ Write a class that maintains the top 10 scores for a game application, implementing the add and remove functions of Section 3.1.1, but

In C++

Write a class that maintains the top 10 scores for a game application, implementing the add and remove functions of Section 3.1.1, but use a singly linked list instead of an array. Test all functionalities in the main function

You must submit all coding files and 1 pdf file with the explanation.

GameEntry class

#ifndef GAMEENTRY_H_ #define GAMEENTRY_H_

#include #include using namespace std; #include

class GameEntry { public:

GameEntry(const string& n="", int s=0); // constructor ~GameEntry();

string getName() const; // get player name, this is a constant inside this member function int getScore() const; // get score

public: string name; // players name int score; // players score };

#endif /* GAMEENTRY_H_ */

GENode class

#ifndef DENODE_H_ #define DENODE_H_

#include

using namespace std;

class GENode{ public: private: GameEntry elem; //data GENode *next; GENode *prev; };

#endif

Scores class

#ifndef SCORES_H_ #define SCORES_H_

#include "GameEntry.h" #include "GENode.h" #include

#include "IndexOutOfBounds.h"

class Scores { public: Scores(int maxEnt = 10); // constructor ~Scores(); // destructor

void add(const GameEntry& e); // add a game entry

GameEntry remove(int i) throw(IndexOutOfBounds); // remove the ith entry

bool Empty(); int operator[](int INDEX); int Size() const; void printAll(); void printIndex(int indx) throw(IndexOutOfBounds);

private: int maxEntries; // maximum number of entries int numEntries; // actual number of entries GENode* head; // head of the singly linked list GENode* tail; //end of the singly linked list };

#endif /* SCORES_H_ */

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!