-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent.cpp
118 lines (102 loc) · 1.77 KB
/
student.cpp
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "student.h"
#include "array.h"
#include "price.h"
// default constructor
Student::Student()
{
first_name = "unknown";
last_name = "unknown";
gender = 'x';
stuID = -1;
}
// constructor that takes a first & last name, and gender
Student::Student(string fn, string ln, char gen, int id)
{
first_name = fn;
last_name = ln;
gender = gen;
num_class = 0;
arr_class[MAX];
stuID = id;
}
// adds class
int Student::addCourse(int crn)
{
int notfound; // stores index, -1 otherwise
notfound = find(arr_class, num_class, crn);
if(notfound == -1) // key not found, no duplicate
{
if(num_class < MAX) // checks if space in array
{
arr_class[num_class++] = crn;
return 1;
}
else // array is full
{
return -1;
}
}
else // index was found
{
return 0;
}
}
// displays all of courses
void Student::viewAllCourses(const Student& s) const
{
print(arr_class, num_class);
}
// removes a class
// returns true if found key to remove, otherwise false
bool Student::dropCourse(int& crn)
{
bool remove_found;
remove_found = remove(arr_class, num_class, crn);
if(remove_found)
{
num_class--;
return true;
}
else
{
return false;
}
}
string Student::getFirstName() const
{
return first_name;
}
string Student::getLastName() const
{
return last_name;
}
char Student::getGender() const
{
return gender;
}
int Student::getNumClasses() const
{
return num_class;
}
int Student::getstuID() const
{
return stuID;
}
int Student::getClassOf(int i) const
{
return arr_class[i];
}
Price Student::getBalance() const
{
return balance;
}
void Student::addFee(int d, int c)
{
Price p(d, c);
balance = p+balance;
}
void Student::reduceFee(int d, int c)
{
Price p(d, c);
balance = balance-p;
}