forked from CEN4020-Fall/assignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJet.cpp
More file actions
53 lines (44 loc) · 1.24 KB
/
Jet.cpp
File metadata and controls
53 lines (44 loc) · 1.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
//
// Created by Jason Santos on 10/4/19.
//
#include "Jet.h"
#include <ctime>
#include <cstdlib>
Jet::Jet() {
setBrand("Custom");
setModel("VTx");
setFuelType("Standard");
this->numberOfEngines = 1;
}
Jet::Jet(string brand, string model, string fuelType, int numberOfEngines) {
setBrand(brand);
setModel(model);
setFuelType(fuelType);
setNumberOfEngines(numberOfEngines);
}
Jet::~Jet() = default;
void Jet::setNumberOfEngines(int numberOfEngines){
this->numberOfEngines = numberOfEngines;
}
int Jet::getNumberOfEngines(){
return (this->numberOfEngines);
}
/* If a jet has more than one engine and rocket fuel,
* the mileage is increased by .055 for every engine
* it has.
*/
double Jet::mileageEstimate(double time) {
std::srand(std::time(NULL));
int rand = std::rand() %(100 - 40 + 1) + 40;
double mileage = rand * time;
if (fuelType == "Rocket" && this->numberOfEngines > 1) {
mileage += mileage * (0.055 * this->numberOfEngines);
}
return mileage;
}
//getNumberOfEngines returns an int so it must be converted
//with to_string
string Jet::toString() {
return "-> Jet\n" + PoweredVehicle::toString() + "\n\tNumber of engines: " +
to_string(getNumberOfEngines());
}