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
43 lines (38 loc) · 1.02 KB
/
Jet.cpp
File metadata and controls
43 lines (38 loc) · 1.02 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
//
// Created by Andres Paz
//
#include "Jet.h"
//default constructor
Jet::Jet(string brand, string model, string fuelType, int numEngines) {
setBrand(brand);
setModel(model);
setFuelType(fuelType);
setNumberOfEngines(numEngines);
}
//set function
void Jet::setNumberOfEngines(int numEngines) {
numberOfEngines = numEngines;
}
//get function
int Jet::getNumberOfEngines() {
return numberOfEngines;
}
//deconstructor
Jet::~Jet() = default;
//needed help implementing this
//Jet message
string Jet::toString() {
return "-> Jet\n" + PoweredVehicle::toString() + "\n\tNumber of engines: " +
to_string( getNumberOfEngines() );
}
//needed help implementing this
//mileage estimate -- creates a random num (40-100) and updates milage based on credentials
double Jet::mileageEstimate(double time) {
int r = rand() % 60+40;
double mileage = r * time;
if ( getNumberOfEngines() > 2 && fuelType == "Rocket" )
{
mileage += mileage * ( 5.5 * getNumberOfEngines() );
}
return mileage;
}