-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
72 lines (63 loc) · 1.57 KB
/
Copy pathGame.cpp
File metadata and controls
72 lines (63 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/******************************************************************************
Aryan Kapoor
*******************************************************************************/
// Class imports below
#include "Game.h"
#include <iomanip>
/*
* Default constructor, sets the base values for all of the class attributes
*/
Game::Game() {
name = "";
highScore = 0;
initials = "";
plays = 0;
revenue = 0;
}
/*
* Overloaded constructor, passing in values for all of the class attributes
*/
Game::Game(std::string n, long s, std::string i, int p) {
name = n;
highScore = s;
initials = i;
plays = p;
revenue = plays * 0.25;
}
/*
* Overloaded less than operator, based off of the highScore attribute
*/
bool Game::operator<(Game& g) {
if (name < g.name)
return true;
else
return false;
}
/*
* Overloaded greater than operator, based off of the highScore attribute
*/
bool Game::operator>(Game& g) {
if (name > g.name)
return true;
else
return false;
}
/*
* Overloaded equals operator, based on if two highScores are equivalent
*/
bool Game::operator==(Game& g) {
if (name == g.name)
return true;
else
return false;
}
/*
* Overloaded insertion operator, prints out the content of the game, displaying
* the name and content of different attirbutes
*/
std::ostream& operator<<(std::ostream& os, const Game& g) {
os << g.name << ", " << g.highScore << ", " << g.initials << ", ";
os << g.plays << ", $" << std::fixed << std::setprecision(2);
os << g.revenue << std::endl;
return os;
}