forked from CEN4020-Fall/assignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJet.cpp
54 lines (37 loc) · 1.21 KB
/
Jet.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
#include "Jet.h"
/* constructors */
Jet::Jet() {
setBrand("Custom");
setModel("unknown");
}
Jet::Jet(string brand, string model, string fuelType, int numberOfEngines) {
setBrand(brand);
setModel(model);
setFuelType(fuelType);
setNumberOfEngines(numberOfEngines);
}
/***************/
// destructor
Jet::~Jet() = default;
// accessor function returns number of engines
int Jet::getNumberOfEngines() {
return numberOfEngines;
}
// change the number of engines
void Jet::setNumberOfEngines(int numEngines) {
numberOfEngines = numEngines;
}
double Jet::mileageEstimate(double t) {
// get random number between 40 and 100 for the mileage
// ( high - low + 1 ) + low
double mileage = floor(rand() % (100 - 40 + 1) + 40) * t;
// if the number of engines is > 2 and the fuel type is "Rocket," boost mileage by 5.5% per engine
if (numberOfEngines > 2 && fuelType == "Rocket")
mileage += mileage * (numberOfEngines * 0.055);
return mileage;
}
// output the details of PoweredVehicle object
string Jet::toString() {
return "-> Jet\n" + PoweredVehicle::toString() + "\n\tNumber of Engines: " +
to_string(getNumberOfEngines());
}