-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcourse.cpp
More file actions
104 lines (86 loc) · 1.91 KB
/
Copy pathcourse.cpp
File metadata and controls
104 lines (86 loc) · 1.91 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
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
#include "course.hh"
Course::Course(std::string code, std::string name, int credits):
course_code_(code), name_(name), credits_(credits)
{
}
Course::~Course()
{
for ( Instance* inst : instances_ ){
delete inst;
}
}
void Course::print_info(bool print_new_line)
{
std::cout << course_code_ << " : " << name_;
if(print_new_line) {
std::cout << std::endl;
}
}
void Course::print_staff()
{
std::cout << "* Staff: " << std::endl;
for (auto acc : course_staff_ ){
acc->print();
}
}
void Course::print_long_info()
{
std::cout << "* Course name: " << name_ << std::endl
<< "* Code: " << course_code_ << std::endl;
print_staff();
std::cout << "* Instances: " << std::endl;
for ( auto instance : instances_ ){
instance->print();
}
}
void Course::print_signups()
{
for ( auto inst : instances_ ){
inst->print();
inst->print_students();
}
}
void Course::add_staff(Account *new_staff)
{
for(unsigned int i = 0; i < course_staff_.size(); ++i)
{
if(course_staff_.at(i) == new_staff)
{
std::cout << STAFF_EXISTS << std::endl;
return;
}
}
course_staff_.push_back(new_staff);
std::cout << STAFF_ADDED << std::endl;
}
void Course::new_instance(Instance *n_instance)
{
instances_.push_back(n_instance);
std::cout << INSTANCE_ADDED << std::endl;
}
bool Course::has_instance(const std::string &name)
{
for ( auto inst : instances_ ){
if ( inst->is_named(name)){
return true;
}
}
return false;
}
Instance *Course::get_instance(std::string name)
{
for ( Instance* inst : instances_ ){
if ( inst->is_named(name) ){
return inst;
}
}
return nullptr;
}
const std::string Course::get_code() const
{
return course_code_;
}
int Course::get_credits() const
{
return credits_;
}