-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.java
More file actions
442 lines (391 loc) · 23.5 KB
/
App.java
File metadata and controls
442 lines (391 loc) · 23.5 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
import java.util.ArrayList;
import java.util.Scanner;
public class App {
public static void main(String[] args) {
// customer account objects
Account c1=new Customer("shaaleissa20","shahad aleissa","shahad1234","0555189040","saudi Arbia/Dammam/9287");
Account c2=new Customer("shahad.iau","shahad ALshammary","shahad1234","0555163240","saudi Arbia/Dammam/9287");
// admin account objects
Account a1=new Admin("fatima.iau","fatima ","fatima1234","0555168340","saudi Arbia/khobar/9287");
Account a2=new Admin();
// agent account objects
Account d1=new Distributor("James.orders11","James ","James3319","0555169080","saudi Arbia/khobar/9287");
Account d2=new Distributor();
Distributor d3=new Distributor();
//Books objects
Books b1=new Books();
Books b2=new Books();
Books b3=new Books();
ArrayList<Books> newBooks=new ArrayList<Books>();
newBooks.add(b1);
newBooks.add(b2);
newBooks.add(b3);
// Journals Book objects
Books j1=new Journals(1, "stories", 1, 190, 4, true);
// StudyBooks Book Objects
Books s1=new Studybooks(2, "Math", 2, 119, 9, true);
// Magazines Book objects
Books m1=new Magazines(6, "Vouge", 3, 100, 3, true);
// total array list of books
ArrayList<Books> totalBooks= new ArrayList<Books>();
totalBooks.add(m1);
totalBooks.add(s1);
totalBooks.add(j1);
Books.numOfBooks=totalBooks.size();
// total array list of accounts
ArrayList<Account> totalAcc=new ArrayList<Account>();
//customers
totalAcc.add(c1);
totalAcc.add(c2);
//admins
totalAcc.add(a1);
totalAcc.add(a2);
//agents
totalAcc.add(d1);
totalAcc.add(d2);
Account.numOfAccount=totalAcc.size();
Scanner input=new Scanner(System.in);
int choice;
boolean keepRolling=true;
while(keepRolling){
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ SFK BookStore Welocmes You ♥ ");
System.out.println(" ♥ Who is Using Our System Today ? ♥ ");
System.out.println(" ♥ 1- Admin ♥ ");
System.out.println(" ♥ 2- Customer ♥ ");
System.out.println(" ♥ 3- Disturbuting Agent ♥ ");
System.out.println(" ♥ 4- Exit The System♥ ");
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ Please Enter : ♥ ");
System.out.println("-----------------------------------------------------------------------------");
choice=input.nextInt();
switch(choice){
case 1:
boolean keepItUp=true;
for(int i=0; i<totalAcc.size(); i++){
if(totalAcc.get(i) instanceof Admin){
Account temp = new Account();
while(keepItUp){
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ Hello Dear Admin!♥ ");
System.out.println(" ♥ 1-Create Account ♥ ");
System.out.println(" ♥ 2-Sign in ♥ ");
System.out.println(" ♥ 3-Functions Of Admin♥ ");
System.out.println(" ♥ 4-Exit System ♥ ");
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ Please Enter : ♥ ");
System.out.println("-----------------------------------------------------------------------------");
int what;
what=input.nextInt();
switch(what){
case 1:
do{
System.out.println("--------------------------------------------------------------");
System.out.println("Please enter a userName that satisfy the following conditions:\n" +
" 1. start with characters \n" +
" 2. Number of characters must be between 8 to 15.");
String username= input.next();
totalAcc.get(i).setUsername(username);
System.out.println("\nPlease enter a Password that satisfy the following conditions:\n" +
" 1. have at least eight characters.\n" +
" 2. consists of only letters and digits.\n" +
" 3. must contain at least two digits.");
String pass= input.next();
totalAcc.get(i).setPassword(pass);
System.out.println("\nPlease enter your name:");
String name= input.next();
totalAcc.get(i).setName(name);
System.out.println("\nPlease enter your phone number:");
String phone_no= input.next();
totalAcc.get(i).setPhone_no(phone_no);
System.out.println("\nPlease enter your address (city name):");
String addres= input.next();
totalAcc.get(i).setAddress(addres);
totalAcc.get(i).existAccount.add(totalAcc.get(i));
temp=totalAcc.get(i);
}while(!temp.SignUp());
break;
case 2:
System.out.println("--------------------------------------------------------------");
totalAcc.get(i).validateLogin(totalAcc.get(i));
break;
case 3:
if(totalAcc.get(i).validateLogin(totalAcc.get(i))==true){
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ 1-Add Books ♥ ");
System.out.println(" ♥ 2-Checks Number of Orders ♥ ");
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ Please Enter : ♥ ");
System.out.println("-----------------------------------------------------------------------------");
int functions=input.nextInt();
switch(functions){
case 1: {
System.out.println("--------------------------------------------------------------");
System.out.println("Enter type of book you want to add:");
System.out.println("1 for journals :");
System.out.println("2 for studybooks :");
System.out.println("3 for magazines :");
int ch=input.nextInt();
newBooks.get(i).AddBooks(ch);}
break;
case 2:{
System.out.println("--------------------------------------------------------------");
System.out.println("The number of current orders are: "+ Order.numOfOrders);
System.out.println("Total Order:");
System.out.println(c1.getCart().getFinalOrder().getBookOrder());}
break;
default: System.out.println("Choice doesn't exist in the menu try again 😄");
break;
}
}
break;
case 4:
System.out.println("--------------------------------------------------------------");
System.out.println(" ♥♥ Bye Bye ♥♥ ");
keepItUp=false;
break;
default:
System.out.println("Choice doesn't exist in the menu try again 😄");
break;
}
}}}
break;
case 2:
boolean keepgoing=true;
for(int i=0; i<=totalAcc.size(); i++){
if(totalAcc.get(i) instanceof Customer){
while(keepgoing){
int answer;
Account temp =new Account();
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ Hello Dear Customer!♥");
System.out.println(" ♥ 1-Create Account ♥ ");
System.out.println(" ♥ 2-Sign in ♥ ");
System.out.println(" ♥ 3-Shopping Cart System ♥ ");
System.out.println(" ♥ 4-Help Center♥ ");
System.out.println(" ♥ 5-Exit System ♥ ");
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ Please Enter : ♥ ");
System.out.println("-----------------------------------------------------------------------------");
answer=input.nextInt();
switch(answer){
case 1:
do{
System.out.println("--------------------------------------------------------------");
System.out.println("Please enter a userName that satisfy the following conditions:\n" +
" 1. start with characters \n" +
" 2. Number of characters must be between 8 to 15.");
String username= input.next();
totalAcc.get(i).setUsername(username);
System.out.println("\nPlease enter a Password that satisfy the following conditions:\n" +
" 1. have at least eight characters.\n" +
" 2. consists of only letters and digits.\n" +
" 3. must contain at least two digits.");
String pass= input.next();
totalAcc.get(i).setPassword(pass);
System.out.println("\nPlease enter your name:");
String name= input.next();
totalAcc.get(i).setName(name);
System.out.println("\nPlease enter your phone number:");
String phone_no= input.next();
totalAcc.get(i).setPhone_no(phone_no);
System.out.println("\nPlease enter your address (city name):");
String addres= input.next();
totalAcc.get(i).setAddress(addres);
totalAcc.get(i).existAccount.add(totalAcc.get(i));
temp=totalAcc.get(i);
}while(!temp.SignUp());
break;
case 2:
System.out.println("--------------------------------------------------------------");
totalAcc.get(i).validateLogin(totalAcc.get(i));
break;
case 3:
if(totalAcc.get(i).validateLogin(totalAcc.get(i))==true){
System.out.println("--------------------------------------------------------------");
boolean keepGoing=true;
while(keepGoing){
int ch;
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" 🛒 Welcome To Shopping Cart System 🛒");
System.out.println(" 1 to add books");
System.out.println(" 2 to place order ");
System.out.println(" 3 to show invoice");
System.out.println(" 4 more info about a book ");
System.out.println(" 5 to cancel order");
System.out.println(" 6 to exit shopping cart system");
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ Please Enter : ♥ ");
System.out.println("-----------------------------------------------------------------------------");
ch=input.nextInt();
switch(ch){
case 1:
for(int j=0; j<totalBooks.size(); j++){
System.out.println(""+totalBooks.get(j).toString());
System.out.println("--------------------------------------------------------------");
}
System.out.println("--------------------------------------------------------------");
System.out.println(" ");
System.out.println("Enter the type of book you want to add :");
System.out.println("1 for journals :");
System.out.println("2 for studybooks :");
System.out.println("3 for magazines :");
int choosenType=input.nextInt();
if(choosenType==1){
for(int j=0; j<totalBooks.size(); j++)
if(totalBooks.get(j).getType()==1)
totalAcc.get(i).getCart().AddBook(ch, totalAcc.get(i), totalBooks.get(j));
}
if(choosenType==2){
for(int j=0; j<totalBooks.size(); j++)
if(totalBooks.get(j).getType()==2)
totalAcc.get(i).getCart().AddBook(ch, totalAcc.get(i), totalBooks.get(j));
}
if(choosenType==3){
for(int j=0; j<totalBooks.size(); j++)
if(totalBooks.get(j).getType()==3)
totalAcc.get(i).getCart().AddBook(ch, totalAcc.get(i), totalBooks.get(j));
}
break;
case 2:
System.out.println("--------------------------------------------------------------");
totalAcc.get(i).getCart().PlaceOrder(totalAcc.get(i), totalAcc.get(i).getCart().getOrder(), d3);
d3.Deliveryfee(totalAcc.get(i).getCart().getDistance());
break;
case 3:
System.out.println("--------------------------------------------------------------");
totalAcc.get(i).getCart().setTotalPrice(totalAcc.get(i).getCart().getTotalPrice()+d3.deliveryfee);
totalAcc.get(i).getCart().showBill(totalAcc.get(i));
break;
case 4:
for(int j=0; j<totalBooks.size(); j++){
System.out.println("What type of book would you like information about? ");
System.out.print("1 for journals, 2 for study books, 3 for magazine: ");
int type= input.nextInt();
totalBooks.get(j).ViewInfo(totalBooks,type);
break;
}
break;
case 5:
System.out.println("--------------------------------------------------------------");
totalAcc.get(i).getCart().cancelOrder(totalAcc.get(i));
break;
case 6: System.out.println("Thank you for shopping with us");
keepGoing=false;
break;
default:
System.out.println("Choice doesn't exist in the menu try again 😄");
break;
}
}}
break;
case 4:
Customer.helpcenter();
break;
case 5:{
System.out.println("");
System.out.println(" ♥♥ Bye Bye ♥♥ ");
System.out.println("");
keepgoing=false;
break;}
default:{
System.out.println("Choice doesn't exist in the menu try again 😄");
break;}
}
}}
break; }
break;
case 3:
boolean rollIt=true;
for(int i=0; i<=totalAcc.size(); i++){
if(totalAcc.get(i) instanceof Distributor){
while(rollIt){
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ Hello Dear Agent!♥ ");
System.out.println(" ♥ 1-Create Account ♥ ");
System.out.println(" ♥ 2-Sign in ♥ ");
System.out.println(" ♥ 3-Functions of the Agent ♥ ");
System.out.println(" ♥ 4-Exit System ♥ ");
System.out.println(" -----------------------------------------------------------------------------");
System.out.println("♥ Please Enter : ♥ ");
System.out.println("-----------------------------------------------------------------------------");
int what;
what=input.nextInt();
Account temp=new Account();
switch(what){
case 1:
do{
System.out.println("--------------------------------------------------------------");
System.out.println("Please enter a userName that satisfy the following conditions:\n" +
" 1. start with characters \n" +
" 2. Number of characters must be between 8 to 15.");
String username= input.next();
totalAcc.get(i).setUsername(username);
System.out.println("\nPlease enter a Password that satisfy the following conditions:\n" +
" 1. have at least eight characters.\n" +
" 2. consists of only letters and digits.\n" +
" 3. must contain at least two digits.");
String pass= input.next();
totalAcc.get(i).setPassword(pass);
System.out.println("\nPlease enter your name:");
String name= input.next();
totalAcc.get(i).setName(name);
System.out.println("\nPlease enter your phone number:");
String phone_no= input.next();
totalAcc.get(i).setPhone_no(phone_no);
System.out.println("\nPlease enter your address (city name):");
String addres= input.next();
totalAcc.get(i).setAddress(addres);
totalAcc.get(i).existAccount.add(totalAcc.get(i));
temp=totalAcc.get(i);
}while(!temp.SignUp());
break;
case 2:
System.out.println(" -----------------------------------------------------------------------------");
totalAcc.get(i).validateLogin(totalAcc.get(i));
break;
case 3:
if(totalAcc.get(i).validateLogin(totalAcc.get(i))==true){
System.out.println(" -----------------------------------------------------------------------------");
System.out.println(" ♥ 1-Confirms Orders♥ ");
System.out.println(" ♥ 2-Prints Delivary Confirmation♥ ");
System.out.println(" -----------------------------------------------------------------------------");
System.out.println("♥ Please Enter : ♥ ");
System.out.println("-----------------------------------------------------------------------------");
int function=input.nextInt();
switch(function){
case 1:
d3.setDeliveryStatus();
System.out.print("Order Set");
break;
case 2:
d3.delivaryConf();
break;
default: System.out.println("Choice doesn't exist in the menu try again 😄");
break;
}
}
break;
case 4:
System.out.println("");
System.out.println(" ♥♥ Bye Bye ♥♥ ");
System.out.println("");
rollIt=false;
break;
default:
System.out.println("Choice doesn't exist in the menu try again 😄");
break;
}
} break; }
}
break;
case 4: System.out.println(" ♥♥ Thank You For Using Our System We Wish You A Pleasent Day ♥♥ ");
keepRolling=false;
break;
default:
System.out.println("Choice doesn't exist in the menu try again 😄");
break;
}
}
}
}