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
37 lines (30 loc) · 882 Bytes
/
Jet.cpp
File metadata and controls
37 lines (30 loc) · 882 Bytes
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
//
// Created by Keith Van Dyke on 10/04/19
//
#include <cmath>
#include <cstdlib>
#include "Jet.h"
Jet::Jet(string brand, string model, string fuelType, int numEngines) {
setBrand(brand);
setModel(model);
setEngineCount(numEngines);
setFuelType(fuelType);
}
Jet::~Jet() = default;
int Jet::getEngineCount() {
return numberOfEngines;
}
void Jet::setEngineCount(int numEngines) {
numberOfEngines = numEngines;
}
double Jet::mileageEstimate(double time) {
double mileage = floor(((rand() % 60) + 41) * time); //generate 40-100
if (fuelType == "Rocket" && numberOfEngines > 2) {
mileage += (mileage * 0.055) * numberOfEngines; //increase 5.5% of mileage for each engine
}
return mileage;
}
string Jet::toString() {
return "-> Jet\n" + PoweredVehicle::toString() + "\n\tEngines: " +
to_string(numberOfEngines);
}