-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirma.cpp
More file actions
145 lines (127 loc) · 3.48 KB
/
firma.cpp
File metadata and controls
145 lines (127 loc) · 3.48 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "firma.h"
Firma::Firma()
{
profesori.clear();
feedback_lists.clear();
elevi.clear();
positions.clear();
task_list.clear();
}
Firma::Firma(const Firma& f)
{
profesori = f.profesori;
feedback_lists = f.feedback_lists;
elevi = f.elevi;
positions = f.positions;
task_list = f.task_list;
}
Firma::Firma(std::vector<Profesor> a, std::vector<std::string> b, std::vector<Elev> c, std::map<std::string, int> x, std::vector<Task> d)
{
profesori = a;
feedback_lists = b;
elevi = c;
positions = x;
task_list = d;
}
Firma::~Firma()
{
profesori.clear();
feedback_lists.clear();
elevi.clear();
}
Firma Firma::operator=(const Firma& firma)
{
this->profesori = firma.profesori;
this->feedback_lists = firma.feedback_lists;
this->elevi = firma.elevi;
return *this;
}
std::ostream& operator<<(std::ostream& output, const Firma& Firma)
{
output << "Lista profesori: " << '\n';
for (int i = 0; i < (int)Firma.profesori.size(); ++i)
{
Profesor prof = Firma.profesori[i];
output << prof.get_name() << " ";
}
output << '\n';
output << "Lista feedback: " << '\n';
for (int i = 0; i < (int)Firma.feedback_lists.size(); ++i)
{
std::string feedback = Firma.feedback_lists[i];
output << feedback << " ";
}
return output;
}
void Firma::add_teacher(std::string nume, std::string adresa)
{
Profesor x(nume, adresa);
profesori.push_back(x);
}
void Firma::add_feedback(std::string feedback)
{
feedback_lists.push_back(feedback);
}
void Firma::detailed_feedback(int wh, std::string feedback)
{
Profesor y = profesori[wh - 1];
y.add_feedback(feedback);
int val = y.rate_feedback(feedback);
y.add_score(val);
}
Profesor Firma::get_data(int nr)
{
if(nr - 1 >= profesori.size())
throw std::length_error("Nu exista acest profesor, verificati datele elevului corespunzator");
return profesori[nr - 1];
}
Elev Firma::get_student(std::string nume_elev)
{
if(positions.find(nume_elev) == positions.end())
throw std::length_error("Nu exista acest elev, verificati datele introduse");
return elevi[positions[nume_elev]];
}
int Firma::find_position(std::string nume_elev)
{
if(positions.find(nume_elev) == positions.end())
return -1;
return positions[nume_elev];
}
void Firma::add_task(Task tsk)
{
task_list.push_back(tsk);
}
void Firma::add_edu_task(Educational_Task tsk)
{
edu_task_list.push_back(tsk);
}
void Firma::add_student(Elev e)
{
elevi.push_back(e);
positions[e.get_name()] = (int) elevi.size() - 1;
}
void Firma::modify_position(int poz, Elev e)
{
elevi[poz] = e;
}
Educational_Task Firma::get_edu_task(int nr)
{
if(nr >= (int) edu_task_list.size())
throw std::length_error("Nu exista aceasta problema");
return edu_task_list[nr];
}
void Firma::add_difficulty(int type, int position, int value)
{
if(type == 0 && position >= (int) task_list.size())
throw std::length_error("Nu exista aceasta problema");
else
if(type == 1 && position >= (int) edu_task_list.size())
throw std::length_error("Nu exista aceasta problema");
else
{
if(type == 0)
task_list[position].add_difficulty(value);
else
edu_task_list[position].add_difficulty(value);
}
}