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.19 KB
/
Jet.cpp
File metadata and controls
53 lines (44 loc) · 1.19 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 Nicholas Watts on Oct 4, 2019
//The functions in this file are modeled on those in Car.cpp and Bicycle.cpp,
//except for where changes were made, as annotated.
#include "Jet.h"
Jet::Jet()
{
numberOfEngines = 0;
setBrand("Unknown");
setModel("Unknown");
}
Jet::Jet(string brand, string model, string fuelType, int numEngines)
{
setBrand(brand);
setModel(model);
setFuelType(fuelType);
setNumberEngines(numEngines);
}
Jet::~Jet() = default;
int Jet::getNumberEngines()
{
return numberOfEngines;
}
//NW If the number of engines provided is less than zero, it stays the same.
//Otherwise, the number of engines is updated.
void Jet::setNumberEngines(int newNum)
{
if (newNum >= 0)
numberOfEngines = newNum;
}
//NW This function has been changed to match the specifications as given in the
//.pdf provided for the assignment.
double Jet::mileageEstimate(double p_time)
{
srand(time(NULL));
double mileage = rand() % 60 + 40.0;
if (numberOfEngines > 2 && fuelType == "Rocket")
mileage += mileage * 0.055 * numberOfEngines;
return mileage;
}
string Jet::toString()
{
return "-> Jet\n" + PoweredVehicle::toString() + "\n\tNumber of Engines: " +
to_string(getNumberEngines());
}