-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
143 lines (135 loc) · 5.02 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
134
135
136
137
138
139
140
141
142
143
#include <iostream>
#include <sstream>
#include <iostream>
#include <string>
#include <cstdlib>
#include <fstream>
#include "AddList.h"
using namespace std;
AddList mylist;
void displayMainMenu(int &select) // main display menu
{
cout << "Welcome to Nathan's List:" << endl;
cout << "" << endl;
cout << "1. Search" << endl;
cout << "2. Sell" << endl;
cout << "3. End Program" << endl;
cin >> select;
}
void displayItemMenu(int &select) // sub display menu
{
cout << "" << endl;
cout << "1. Cars " << endl;
cout << "2. Electronics " << endl;
cout << "3. Bikes " << endl;
cout << "4. Free " << endl;
cout << "5. Return to main menu " << endl;
cin >> select;
}
int main()
{
List *carList = new List(); // declare and allocate memory for new list
List *electronicList = new List();
List *bikeList = new List();
List *freeList = new List();
int select = 0;
bool exit = false;
while(!exit) {
displayMainMenu(select);
switch(select) {
case 1:
{
bool exit1 = false;
while(!exit1){
cout << "" << endl;
cout << "Search for:" << endl;
displayItemMenu(select);
switch(select) {
case 1:
cout << "Cars for sale: " << endl;
cout << "" << endl;
mylist.PrintList(carList);
break;
case 2:
cout << "Electronics for sale: " << endl;
cout << "" << endl;
mylist.PrintList(electronicList);
break;
case 3:
cout << "Bikes for sale: " << endl;
cout << "" << endl;
mylist.PrintList(bikeList);
break;
case 4:
cout << "Free items: " << endl;
cout << "" << endl;
mylist.PrintList(freeList);
break;
case 5:
exit1 = true;
}
}break;
}
case 2:
{
string inTitle;
string inComments;
int inPrice;
bool exit2 = false;
//List *carList = new List;
while(!exit2){
cout << "" << endl;
cout << "Sell:" << endl;
displayItemMenu(select);
switch(select) {
case 1:
getchar();
cout << "Enter title" << endl;
getline(cin, inTitle);
cout << "Enter comments" << endl;
getline(cin, inComments);
cout << "Enter price" << endl;
cin >> inPrice;
mylist.Add(carList, inTitle, inComments, inPrice);
break;
case 2:
getchar();
cout << "Enter title" << endl;
getline(cin, inTitle);
cout << "Enter comments" << endl;
getline(cin, inComments);
cout << "Enter price" << endl;
cin >> inPrice;
mylist.Add(electronicList, inTitle, inComments, inPrice);
break;
case 3:
getchar();
cout << "Enter title" << endl;
getline(cin, inTitle);
cout << "Enter comments" << endl;
getline(cin, inComments);
cout << "Enter price" << endl;
cin >> inPrice;
mylist.Add(bikeList, inTitle, inComments, inPrice);
break;
case 4:
getchar();
cout << "Enter title" << endl;
getline(cin, inTitle);
cout << "Enter comments" << endl;
getline(cin, inComments);
cout << "Enter price" << endl;
cin >> inPrice;
mylist.Add(freeList, inTitle, inComments, inPrice);
break;
case 5:
exit2 = true;
}
}break;
}
case 3:
exit = true;
break;
}
}
}