-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
133 lines (120 loc) · 3.58 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
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
#include "header.h"
using namespace std;
/*
Piotr Pietrusewicz 53828 120A
West Pomeranian University of Technology
Theme: Car Dealearship
Main file that calls every other function from the menu
*/
void menu(Dealership& dealership) {
int choice = -1;
do {
// Clean the terminal screen
system("CLS");
cout << " Second Term Project\n";
cout << " Piotr Pietrusewicz 53828 120A\n";
cout << " Theme: Car Dealearship\n";
// Line of 68 '=' characters to make it look better
cout << setfill('=') << setw(68) << "=\n\n";
if (dealership.getChosenVehicleType() == CAR) {
cout << " 1 ] Randomize owners and listings _.-.___|__\n";
cout << " 2 ] Add an owner | _ _`-.\n";
cout << " 3 ] Remove an owner '-(_)----(_)--`\n";
}
else if (dealership.getChosenVehicleType() == MOTORCYCLE) {
cout << " 1 ] Randomize owners and listings ,\n";
cout << " 2 ] Add an owner .-/c-.,::\n";
cout << " 3 ] Remove an owner (_)'==(_)\n";
}
cout << " 4 ] Display owners\n";
cout << " 5 ] Add a new listing 99 ] Change current\n";
cout << " 6 ] Edit a listing vehicle type\n";
cout << " 7 ] Delete a listing\n";
cout << " 8 ] Display listings\n";
cout << " 9 ] Search through listings\n";
cout << " 10 ] Confirm sale\n";
cout << " 11 ] Number of vehicles from specified city\n";
cout << " 12 ] Display amount of owners and listings\n";
cout << " 13 ] Check if the owner exists\n";
cout << " 14 ] Display the summed up price of listings\n\n";
cout << " 15 ] Save to a file\n";
cout << " 16 ] Load from a file\n\n";
cout << " 0 ] Exit\n\n";
cin.clear();
cin >> choice;
if (!(choice >= 0 && (choice <= 16 || choice == 99))) {
displayIncorrectNumberMessage();
}
} while (!(choice >= 0 && (choice <= 16 || choice == 99)));
switch (choice) {
case 0:
exit(0);
break;
case 1:
generateRandomizedOwnersAndListings(dealership);
break;
case 2:
addOwnerByUser(dealership);
break;
case 3:
deleteOwnerByUser(dealership);
break;
case 4:
displayOwners(dealership);
break;
case 5:
addListingByUser(dealership);
break;
case 6:
editListing(dealership);
break;
case 7:
deleteUserListing(dealership);
break;
case 8:
displayAllListings(dealership);
break;
case 9:
searchThroughListings(dealership);
break;
case 10:
confirmSale(dealership);
break;
case 11:
vehicleNumberFromCities(dealership);
break;
case 12:
usageOfAnOverloadedOperator(dealership);
break;
case 13:
checkIfOwnerExists(dealership);
break;
case 14:
displayPrices(dealership);
break;
case 15:
saveToAFile(dealership);
break;
case 16:
loadDataFromAFile(dealership);
break;
case 99:
dealership.setTypeCounterAddOne();
dealership.setChosenVehicleType(vehicleTypes[dealership.getTypeCounter() % 2]);
break;
default:
displayIncorrectNumberMessage();
break;
}
}
int main() {
// This enables Polish letters to be displayed in the terminal
setlocale(LC_CTYPE, "Polish");
// Set the seed for the randomizer to the current time to ensure different results each time the program is run
srand((unsigned int)time(nullptr));
// Create an object dealership of a type Dealership to use in the menu function
Dealership& dealership = Dealership::instance();
while (true) {
menu(dealership);
}
}