forked from ucsb-cs24-w22/lab01_data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperf.cpp
39 lines (31 loc) · 1.2 KB
/
perf.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
#include "perf.hpp"
// Not required to understand. Used for Gradescope tests ONLY.
bool PerformanceStats::operator==(PerformanceStats const& o) const{
return this->horsepower == o.horsepower
&& this->zeroToSixtyNs == o.zeroToSixtyNs
&& this->headonDragCoeff == o.headonDragCoeff;
}
bool PerformanceStats::operator!=(PerformanceStats const& o) const{
return !(*this==o);
}
bool PerformanceStats::operator<(PerformanceStats const& o) const{
if(this->zeroToSixtyNs != o.zeroToSixtyNs){
return this->zeroToSixtyNs > o.zeroToSixtyNs;
}else if(this->horsepower != o.horsepower){
return this->horsepower < o.horsepower;
}else{
return this->headonDragCoeff > o.headonDragCoeff;
}
}
bool PerformanceStats::operator>(PerformanceStats const& o) const{
return o<*this;
}
bool PerformanceStats::operator<=(PerformanceStats const& o) const{
return !(*this>o);
}
bool PerformanceStats::operator>=(PerformanceStats const& o) const{
return !(*this<o);
}
std::ostream& operator<<(std::ostream& o, PerformanceStats const& stats){
return o<<"{ 0-60: "<<stats.zeroToSixtyNs<<", horsepower: "<<stats.horsepower<<", headonDragCoeff: "<<stats.headonDragCoeff<<" }";
}