-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.cpp
More file actions
58 lines (47 loc) · 1.01 KB
/
Copy pathStudent.cpp
File metadata and controls
58 lines (47 loc) · 1.01 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
// Student.cpp
// Course: SENG1120
// Coded by: SENG1120 Staff
#include "Student.h"
#include <cstdlib>
// Constructors
Student::Student()
{
name = "";
score = 0;
}
Student::Student(string name_, int score_)
{
name = name_;
score = score_;
}
// empty destructor
Student::~Student(){}
// Mutator methods (setters)
void Student::set_name(const string name_)
{
name = name_;
}
void Student::set_score(const int score_)
{
score = score_;
}
// Accessor methods (getters)
string Student::get_name() const
{
return name;
}
int Student::get_score() const
{
return score;
}
ostream& operator <<(ostream& out, const Student& value)
{
out << "(" << value.get_name() << "," << value.get_score() << ") ";
return out;
}
// Code for overloading operator < for student written by Johanne Montano
// overload < to evaluate if one student did better than the other in terms of score
bool operator <(const Student& lhs, const Student& rhs){
if(lhs.get_score() < rhs.get_score()) {return true;}
else {return false;}
}