-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver.cpp
137 lines (114 loc) · 3.18 KB
/
driver.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* 3 Dealers
* Car Add to specific dealer (I/P: Dealer ID, Car info)
* Sell Car by specific dealer (by Car ID, delerID) [not Done yet]
* Transfer Car from a dealer to another dealer (by DealerID {from and to}, Car ID)
* Add an exact same model of a car from a dealer to another dealer's car inventory (by Car ID) [not Done yet]
* Sort the Cars (Ascending and descending for each dealer) [not Done yet]
* Get the max and min expensive Car (from all dealers)
* store information to a file and read from the file upon starting of the program
* Add Dealer (by Dealer ID) [not Done yet]
* Show All Dealer Inventory
driver.cpp, model.cpp, services.cpp, utils.cpp
*/
#include <iostream>
#include <vector>
#include <vector>
#include <map>
#include <iomanip>
#include "services.cpp"
#define TOTAL_DEALER 3
using namespace std;
void runUserPrompt(vector<CarDealer> &carDealers)
{
string option;
do
{
cout << ":::Dealers::: ";
for (auto dealer : carDealers)
{
cout << "[" << dealer.dealerID << "]"
<< " ";
}
cout << ":::Dealers:::" << endl;
cout << "0 - Cancel\n"
<< "1 - Add Car\n"
<< "2 - Most Expensive Car\n"
<< "3 - Least Expensive Car\n"
<< "7 - Transfer Car to Another Dealer\n"
<< "9 - Show Cars" << endl;
int choice;
cout << "Choose: ";
cin >> choice;
switch (choice)
{
case 1:
{
addCar(carDealers);
break;
}
case 2:
{
// function pointer
Car maxExpCar = customExpCar(carDealers, maxCompare);
cout << "Dealer\t: " << maxExpCar.dealerID << endl;
cout << maxExpCar << endl;
break;
}
case 3:
{
// function pointer
Car minExpCar = customExpCar(carDealers, minCompare);
cout << "Dealer\t: " << minExpCar.dealerID << endl;
cout << minExpCar << endl;
break;
}
case 7:
{
transferCar(carDealers);
break;
}
case 9:
{
showCars(carDealers);
break;
}
case 0:
break;
default:
break;
}
cout << "Type 'exit' to terminate console or any character(s) to proceed\n";
cin >> option;
if (option == "exit")
break;
else
continue;
} while (true);
}
int main()
{
vector<CarDealer> carDealers;
map<string, Car> cars;
CarDealer cd;
cd.dealerID = "D101",
cd.cars = cars;
carDealers.push_back(cd);
cd.dealerID = "D102",
carDealers.push_back(cd);
cd.dealerID = "D103";
carDealers.push_back(cd);
runUserPrompt(carDealers);
// Car car1 = Car("Marcedes Benz", "Black", 35000);
// Car car2 = Car("BMW", "Red", 40000);
// Car car3 = Car("Audi", "Grey", 50000);
// cd += car1;
// cd += car2;
// cd += car3;
// cout << car1 << "\n"
// << car2 << "\n"
// << car3 << endl;
// cout << "====Most Expensive==== \n"
// << getMostExpCar(cd);
return 0;
}