-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
155 lines (128 loc) · 2.85 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
144
145
146
147
148
149
150
151
152
153
154
155
#include <iostream>
#include <string>
#include "Stock.h"
#include "Item.h"
#include <fstream>
#include "User.h"
#include "Admin.h"
#include "Employee.h"
#include "Customer.h"
using namespace std;
void displayIntro();
void displayExit();
void displayMainMenu();
int getChoice();
int whoIsUser();
int main()
{
Stock stock;
displayIntro();
int choice;
string username, password;
do
{
choice = whoIsUser();
switch (choice)
{
case 1:
{
Admin admin;
cout << "User Name: ";
cin.ignore();
getline(cin, username);
if (admin.check())
{
cout << "LOGIN SUCCESSFUL\n";
admin.pauseAndClear();
admin.adminAccess();
}
else
{
system("cls");
cout << "YOU HAVE ENTERED WRONG PASSWORD\n";
admin.pauseAndClear();
}
break;
}
case 2:
{
Employee employee;
cout << "User Name: ";
cin.ignore();
getline(cin, username);
if (employee.check())
{
cout << "LOGIN SUCCESSFUL\n";
employee.pauseAndClear();
employee.employeeAccess();
}
else
{
system("cls");
cout << "YOU HAVE ENTERED THE WRONG PASSWORD\n";
employee.pauseAndClear();
}
break;
}
case 3:
{
Customer customer;
customer.customerAccess();
break;
}
case 4:
{
displayExit();
system("pause");
break;
}
default:
cout << "Invalid choice" << '\n';
break;
}
} while (choice != 4);
return 0;
}
void displayMainMenu()
{
cout << "INVENTOSYNC\n";
cout << "1 - LOGIN AS ADMIN\n";
cout << "2 - LOGIN AS EMPLOYEE\n";
cout << "3 - ENTER TO PURCHASE AS CUSTOMER\n";
cout << "4 - EXIT (ALL CHANGES WILL BE SAVED)\n";
}
int getChoice()
{
int choice = -1;
while (!(choice > 0 && choice < 5))
{
cout << "Enter your choice: ";
cin >> choice;
system("cls");
if (!(choice > 0 && choice < 5))
{
cout << "Please choose a valid number from the following options of menu.\n";
displayMainMenu();
}
cin.clear();
cin.ignore(1000, '\n');
}
return choice;
}
int whoIsUser()
{
displayMainMenu();
return getChoice();
}
void displayIntro()
{
cout << "WELCOME TO INVENTOSYNC\n";
system("pause");
system("cls");
}
void displayExit()
{
cout << "THANK YOU FOR USING THE INVENTOSYNC\n";
system("pause");
system("cls");
}