Last active
August 29, 2015 14:02
-
-
Save RickEyre/57b790235de8c1aa35bd to your computer and use it in GitHub Desktop.
Lawrence Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implement this class fully, including virtual functions. | |
class Score { | |
int mScore; | |
string mName; | |
public: | |
Score(int score, int name); | |
virtual string getName() const; | |
virtual int getScore() const; | |
virtual void printScore() const; | |
inline bool operator<(const Score& myScore) const; | |
}; | |
// Implement this class fully, but slightly alter the getName, getScore, operator<, etc | |
// to be different from base class Score | |
class HighScore : Score { | |
public: | |
HighScore(int score, int name); | |
string getName() const; | |
int getScore const; | |
void printScore() const; | |
inline bool operator<(const HighScore& myScore) const; | |
}; | |
// Implement this fully and then insert a bunch of HighScores and Scores | |
// Call sort and print, see the differences between it using which function | |
// from which class depending on what kind of object it is. | |
class Scores { | |
vector<Score*> scores; | |
public: | |
void addScore(Score* s); | |
void sortScores(); | |
void printScores(); | |
}; | |
// Usage | |
Scores scores; | |
HighScore h1(2, "Lawrence"); | |
HighScore h2(3, "Rick"); | |
Score s1(0, "Someone"); | |
scores.addScore(&h1); | |
scores.addScore(&h2); | |
scores.addScore(&s1); | |
scores.sortScores(); | |
scores.printScores(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment