-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniversidade.cpp
61 lines (61 loc) · 2.19 KB
/
Universidade.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
#include "Universidade.hpp"
#include <iostream>
Universidade::Universidade()
{
this->professores = *new vector<Professor *>();
}
void Universidade::addProfessor(Professor &professor)
{
this->professores.push_back(&professor);
}
double Universidade::totalPago()
{
double TotalPago = 0;
for (int i = 0; i < this->professores.size(); i++)
{
TotalPago += this->professores[i]->getSalario();
}
return TotalPago;
}
void Universidade::listaProfessores()
{
int maior = 13, a = 7;
bool salario = false;
for (int i = 0; i < professores.size(); i++)
{
if (professores[i]->getName().size() > maior)
maior = professores[i]->getName().size();
if (professores[i]->getSalario() >= 1000.0)
salario = true;
}
if (salario)
a++;
for (int i = 0; i < maior + a; i++)
cout << "_";
cout << endl
<< "| Professores |";
if (salario)
cout << " R$ |" << endl;
else
cout << " R$ |" << endl;
for (int i = 0; i < professores.size(); i++)
{
cout << "|";
if (professores[i]->getName().size() < maior)
for (int j = 0; j < maior - professores[i]->getName().size(); j++)
cout << " ";
if (salario == false)
cout << this->professores[i]->getName() << "| " << this->professores[i]->getSalario() << "|" << endl;
else if (this->professores[i]->getSalario() >= 1000)
cout << this->professores[i]->getName() << "| " << this->professores[i]->getSalario() << "|" << endl;
else if (this->professores[i]->getSalario() >= 100)
cout << this->professores[i]->getName() << "| " << this->professores[i]->getSalario() << "|" << endl;
else if (this->professores[i]->getSalario() >= 10)
cout << this->professores[i]->getName() << "| " << this->professores[i]->getSalario() << "|" << endl;
else if (this->professores[i]->getSalario() >= 0)
cout << this->professores[i]->getName() << "| " << this->professores[i]->getSalario() << "|" << endl;
}
for (int i = 0; i < maior + a; i++)
cout << "-";
cout << endl;
}