forked from CEN4020-Fall/assignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
40 lines (34 loc) · 1.27 KB
/
main.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
#include <iostream>
#include "Car.h"
#include "Bicycle.h"
void printVehiclesRoster(Vehicle **vehicles, int size);
int main() {
std::cout << "Driving simulator" << std::endl;
int size = 6;
int capacity = 10;
Vehicle **vehiclesArray = new Vehicle *[capacity];
vehiclesArray[0] = new Car();
vehiclesArray[1] = new Bicycle("eTAP", "P5X");
vehiclesArray[2] = new Bicycle("R&A", "Dogma F8", 5);
vehiclesArray[3] = new Car("Tesla", "T2", "electricity", "large");
vehiclesArray[4] = new Bicycle("Mizuno", "Wave", 10);
vehiclesArray[5] = new Car("BMW", "X5", "diesel", "grande");
printVehiclesRoster(vehiclesArray, size);
if (vehiclesArray != 0) { // If it is not a null pointer
// do not use nullptr. It is not supported on linprog
for (int i = 0; i < size; i++) {
delete vehiclesArray[i];
}
delete[] vehiclesArray;
}
return 0;
}
void printVehiclesRoster(Vehicle **vehicles, int size) {
double simulatedDistance = 130;
for (int i = 0; i < size; i++) {
cout << i << " " << vehicles[i]->toString() << endl;
cout << "\tWould travel: "
<< vehicles[i]->mileageEstimate(simulatedDistance) << " miles in "
<< simulatedDistance << " seconds" << endl;
}
}