-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransm.cpp
More file actions
86 lines (71 loc) · 2.24 KB
/
transm.cpp
File metadata and controls
86 lines (71 loc) · 2.24 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
#include "engine.cpp"
// DICIONÁRIOS
const transm Transm::transmParts[] = {
{"Original Trasmission w/ Short Shifter, Sport Clutch", .2},
{"Sport Trasmission w/ H-Pattern Short Shifter, Sport+ Clutch", .17},
{"Sport Trasmission w/ Sequential Shifter, Racing Clutch", .14},
{"Racing Pneumatic Sequential Trasmission, Racing Clutch", .07}
};
// IMPLEMENTAÇÃO
const double Transm::MINTIME = .1;
const double Transm::MAXTIME = .27;
Transm::Transm(const double &timeSwap) {
this->myTransm = {"Original", timeSwap};
this->timeSwap = timeSwap;
}
Transm::Transm(const Transm &other) {
this->myTransm = other.myTransm;
this->timeSwap = other.timeSwap;
}
const double Transm::getTime() const {
return this->timeSwap;
}
const bool Transm::setTransm() {
const transm transm = getTransm();
if (*this == transm) return 0;
this->timeSwap = transm.timeSwap;
this->myTransm = transm;
return 1;
}
const double Transm::getTimeSwap() {
while (1) {
string input; double timeSwap;
cout << "Digite o tempo de troca de marchas: ";
getline(cin, input);
stringstream stream(input);
if (stream >> timeSwap && MINTIME <= timeSwap
&& timeSwap <= MAXTIME) return timeSwap;
system("cls||clear");
cout << "O tempo deve ficar entre .1 e .27s!\n";
}
}
const transm &Transm::getTransm() {
unsigned opcao;
system("cls||clear");
while (1) {
string input; unsigned cont = 0;
for (transm elem : transmParts)
cout << cont++ << " - " << elem << "\n";
cout << "Qual opcao voce escolhe? ";
getline(cin, input);
stringstream stream(input);
if (stream >> opcao && opcao < cont) break;
system("clear||cls");
cout << "Entrada invalida! Tente de novo!\n";
}
return Transm::transmParts[opcao];
}
// SOBRECARGAS DA CLASSE
ostream &operator<<(ostream &output, const Transm &trasmiss) {
output << "Tempo de Troca: " << trasmiss.timeSwap << "\n";
output << "Transmission: " << trasmiss.myTransm << "\n";
return output;
}
const bool Transm::operator==(const transm &part) const {
return (myTransm.timeSwap == part.timeSwap && myTransm.part == part.part);
}
// SOBRECARGAS DOS STRUCTS
ostream &operator<<(ostream &output, const transm &elem) {
output << elem.part << " - " << elem.timeSwap;
return output;
}