-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOnlineShopping.java
1705 lines (1462 loc) · 44.3 KB
/
OnlineShopping.java
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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package abc;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.*;
//Abstract class
abstract class User{
//protected
protected String Id;
protected String password;
protected String username;
protected String EmailId;
protected String address;
public void User(String name,String password) {
this.username= name;
this.password = password;
}
public void Check_login() {
}
public void Register(int custarr, String name, String pass) {
}
}
//Iheritance class diagram
class Customer extends User{
public String customer_name;
public String customer_Id;
public String phone;
protected String cpassword;
public Customer(String username,String customer_name,String customer_id,String ph,String cpassword,
String EmailId,String address) {
this.username=username;
this.address=address;
this.cpassword=cpassword;
this.customer_Id=customer_id;
this.customer_name=customer_name;
this.EmailId=EmailId;
this.phone=ph;
}
public void Register(int custarr,String username,String cpassword) {
customer_Id="C"+custarr;
String choice;
int i=0;
Scanner scan1=new Scanner(System.in);
System.out.println("Welcome to the #");
System.out.println("Do you want to Fill up ur account details Y/N");
choice=scan1.next();
while(i==0)
{
if(choice=="Y"||choice=="y") {
System.out.println("Enter your name: ");
this.customer_name=scan1.next();
System.out.println("Enter your Address: ");
this.address=scan1.next();
System.out.println("Enter your EmailId: ");
this.EmailId=scan1.next();
System.out.println("Enter your Phoone Number: ");
this.phone=scan1.next();
i=1;
}
else if(choice=="N"||choice=="n") {
i=1;
}
else
{
System.out.println("Please enter Y/N");
}
}
}
public boolean Check_login(String inputus, String inpass) {
if(this.username==inputus&&this.cpassword==inpass)
{
return true;
}
else {
return false;
}
}
public void Check_login() {
System.out.println("Welcome "+this.customer_name);
}
}
//inheritance class diagram
class Admin extends User{
public String admin_Id;
public String admin_name;
public String admin_password;
public String access_code;
public Admin(String username, String name, String id, String passw, String code) {
this.username=username;
this.admin_name=name;
this.admin_Id=id;
this.admin_password=passw;
this.access_code=code;
}
public void Service() {
}
}
class ProductList{
//Arraylist
public ArrayList<product> prdtt= new ArrayList<product>();
public int prdt_no;
public String sizes_available;
public double rating;
public ProductList(ArrayList<product> pr) {
prdtt = new ArrayList<product>(pr);
}
public void filter() {
}
public void sort() {
}
}
//Comparable Interface
class product implements Comparable<product>{
public String prdt_name;
public int prdt_id;
public String prdt_size;
public int price;
public void carting() {
}
public product(int item_no, String item_name, String item_size, int item_price) {
this.prdt_id=item_no;
this.prdt_name=item_name;
this.prdt_size=item_size;
this.price=item_price;
}
public int getprice() {
return price;
}
@Override public String toString()
{
return "name:"+this.prdt_name+" "+"price: "+this.price;
}
@Override
public int compareTo(product ppd) {
int compareage
= ((product)ppd).getprice();
// For Ascending order
return this.price - compareage;
}
}
class StockList {
public int item_no;
public String item_name;
public String item_type;
public char item_gender;
public String item_size;
public int no_of_items;
public int item_price;
public StockList(int i, String string, String string2, char c, String string3, int j, int d) {
this.item_no=i;
this.item_type=string2;
this.item_name=string;
this.item_gender=c;
this.item_size=string3;
this.no_of_items=j;
this.item_price=d;
}
}
class cart {
public int price;
public int cart_id;
public int cart_quantity;
public int prdt_quantity;
public String size;
public void insert(int price2, int prdt_id) {
price=price2;
cart_id=prdt_id;
}
public void modify() {
}
public void buy() {
}
}
//inheritance
class bill extends cart implements buyingPortal {
public int bill_id;
public float bill_amount;
public String name;
public int quant;
@Override
public int voucher(int total,String redeem) {
int tot=0;
if(redeem.equals("abcdef")||redeem.equals("abcdefg")) {
tot=total-(total/10);//10%
System.out.println("Redeemed 10% ("+total/10+") of the Total price!!");
}
if(redeem.equals("wxyz")||redeem.equals("xyz")) {
tot=total-(total/5);//20%
System.out.println("Redeemed 20% ("+total/5+") of the Total price!!");
}
return tot;
}
public void buy(int i) {
this.bill_id=i;
System.out.println("Bill Id: "+bill_id);
System.out.println("Product Name: "+name);
System.out.println("Quantity: "+quant);
System.out.println("Price: "+bill_amount*quant);
}
public void insertbill(int price, String cname, int prdt_id, int cid) {
// TODO Auto-generated method stub
this.bill_amount=price;
this.cart_id=prdt_id;
this.name=cname;
this.quant=cid;
}
}
//Interface
interface buyingPortal {
public int voucher(int total, String redeem) ;
}
//Dependency class
class payment {
String payment_type;
public void addUPI(upi upi) {
if(upi.ok==1) {
System.out.println("UPI Payment successful and Order is placed");
}
}
public void addcard(card card) {
if(card.ok==1) {
System.out.println("CARD Payment successful and order is placed");
}
}
}
//getter and setter
class upi {
private String upi_address;
int ok;
public void setadd(String add) {
this.upi_address=add;
}
public String getok() {
return upi_address;
}
public void check(String addr) {
setadd(addr);
if (getok()!=null) {
ok=1;
}}
}
//private
class card {
private String cardno;
private String cvv;
int ok;
public void setno(String add) {
this.cardno=add;
}
public void setcvv(String add) {
this.cvv=add;
}
public String getok1() {
return cardno;
}
public String getok2() {
return cvv;
}
public void check(String card,String cvv) {
setno(card);
setcvv(cvv);
if (getok1()!=null&&getok2()!=null) {
ok=1;
}}
}
class orders {
String cust_id;
int order_id;
int quant;
String delivery_date;
public void insorders(String o,int cid, int quant2) {
cust_id = o;
order_id = cid;
quant=quant2;
}
}
public class project {
public static void main(String[] args) {
int start=0;
while(start==0) {
int custarr=4,adminarr=3;
String custId = null;
Customer[] cust= new Customer[7];
//File handling
//Exception
File hello = new File("cust.txt");///reading from the text file///
Scanner custreader;
try {
custreader = new Scanner(hello);
String ax,bx,cx,dx,ex,fx,gx;
int index=0;
while(custreader.hasNext())
{
ax=custreader.nextLine();
bx=custreader.nextLine();
cx=custreader.nextLine();
dx=custreader.nextLine();
ex=custreader.nextLine();
fx=custreader.nextLine();
gx=custreader.nextLine();
cust[index]=new Customer(ax,bx,cx,dx,ex,fx,gx);
index=index+1;
}
custreader.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*PrintStream writer;
try {
writer = new PrintStream(new FileOutputStream("cust.txt"));
int index=0;
while(index<cust.length)
{
if(cust[index]!=null)
{
writer.println(cust[index].username);
writer.println(cust[index].customer_name);
writer.println(cust[index].customer_Id);
writer.println(cust[index].phone);
writer.println(cust[index].cpassword);
writer.println(cust[index].EmailId);
writer.println(cust[index].address);
}
index=index+1;
}
writer.close();*/
Admin[] admin= new Admin[4];
admin[0]=new Admin("admin1","Ashok","a0","ashok123","access@123");
admin[1]=new Admin("admin2","Pritham","a1","pri1942","access@234");
admin[2]=new Admin("addoff03","Vignesh","a2","ragu12viggy","access@345");
admin[3]=new Admin("addoff04","Sidharth","a3","sidd123","access@456");
ArrayList<StockList> stockad = new ArrayList<StockList>();
int stocktot=20;
StockList b=new StockList(0,"Desert Sun Solid Full Sleeve Shirt","Shirts",'M',"123",3,799);//1-S,2-M,3-L,4-XL
stockad.add(b);
StockList b01=new StockList(1,"Printed Mandarin Collar Full Shirt","Shirts",'M',"123",3,599);
stockad.add(b01);
StockList b2=new StockList(2,"Modern Noise Red Checks Shirts","Shirts",'M',"123",3,999);
stockad.add(b2);
StockList b3=new StockList(3,"Black Solid Half Sleeve Shirt","Shirts",'M',"123",3,599);
stockad.add(b3);
StockList b4=new StockList(4,"Blue Regular Fit Jeans","Pants",'M',"123",3,1099);
stockad.add(b4);
StockList b5=new StockList(5,"Olive Solid Joggers","Pants",'M',"123",3,899);
stockad.add(b5);
StockList b6=new StockList(6,"Dusty Blue Twill Chino","Pants",'M',"123",3,1299);
stockad.add(b6);
StockList b7=new StockList(7,"Cloud Cream Chino","Pants",'M',"123",3,1299);
stockad.add(b7);
StockList b8=new StockList(8,"'Black AOP Half Street wear T-shirt","T-Shirts",'M',"123",3,599);
stockad.add(b8);
StockList b9=new StockList(9,"'Never Mind Stripe Half Sleeve T-shirt","T-Shirts",'M',"123",3,799);
stockad.add(b9);
StockList b10=new StockList(10,"Make Tracks T-shirt","T-Shirts",'M',"123",3,799);
stockad.add(b10);
StockList b11=new StockList(11,"Iron Man of War T-Shirt","T-Shirts",'M',"123",3,499);
stockad.add(b11);
StockList b12=new StockList(12,"India Ink Raw Hem Shorts","Shorts",'M',"123",3,799);
stockad.add(b12);
StockList b13=new StockList(13,"Killer Brown Color Block Shorts","Shorts",'M',"123",3,649);
stockad.add(b13);
StockList b14=new StockList(14,"White Pride Side Color Binding Shorts","Shorts",'M',"123",3,749);
stockad.add(b14);
StockList b15=new StockList(15,"Indigo Chino Shorts","Shorts",'M',"123",3,849);
stockad.add(b15);
StockList b16=new StockList(16,"Twice As Pretty Sweater Top","Shirts",'F',"123",3,2499);
stockad.add(b16);
StockList b17=new StockList(17,"Green Flaunt Your Style Top","Shirts",'F',"123",3,1599);
stockad.add(b17);
StockList b18=new StockList(18,"Red Look At You Cute Sweater","Shirts",'F',"123",3,2299);
stockad.add(b18);
StockList b19=new StockList(19,"Green Look At You Cute Sweater Top","Shirts",'F',"123",3,3199);
stockad.add(b19);
StockList b20=new StockList(20,"Black Solid Flared Jeans","Pants",'F',"123",3,1499);
stockad.add(b20);
StockList b21=new StockList(21,"Women Brown Solid Flared Jeans","Pants",'F',"123",3,1299);
stockad.add(b21);
StockList b22=new StockList(22,"Blue Solid Flared Jeans","Pants",'F',"123",3,999);
stockad.add(b22);
StockList b23=new StockList(23,"Women Brown Solid Flared Jeans","Pants",'F',"123",3,1399);
stockad.add(b23);
StockList b24=new StockList(24,"Choose Colors That Never Fade Dress","T-Shirts",'F',"123",3,1099);
stockad.add(b24);
StockList b25=new StockList(25,"Happy Days Like These Dress","T-Shirts",'F',"123",3,659);
stockad.add(b25);
StockList b26=new StockList(26,"Red Look At You Cute t-shirt","T-Shirts",'F',"123",3,899);
stockad.add(b26);
StockList b27=new StockList(27,"'Green Look At You Cute t-shirt","T-Shirts",'F',"123",3,999);
stockad.add(b27);
StockList b28=new StockList(28,"Super sport sports","Shorts",'F',"123",3,1299);
stockad.add(b28);
StockList b29=new StockList(29,"Slim fit beige shorts","Shorts",'F',"123",3,659);
stockad.add(b29);
StockList b30=new StockList(30,"Jean style shorts","Shorts",'F',"123",3,799);
stockad.add(b30);
StockList b31=new StockList(31,"thug fit shots","Shorts",'F',"123",3,899);
stockad.add(b31);
int stockint=19;
//final keyword
final int pdtlist=7;
ProductList[] prdt=new ProductList[8];
ArrayList<product> pr= new ArrayList<product>();
int x=-1;
for(int j=0;j<stockad.size();j++) {
if(stockad.get(j).item_type.equals("Shirts")&&stockad.get(j).item_gender=='M') {
x=x+1;
product pr1=new product(stockad.get(j).item_no,stockad.get(j).item_name,stockad.get(j).item_size,stockad.get(j).item_price);
pr.add(pr1);
}
}
prdt[0]=new ProductList(pr);
pr.clear();
x=-1;
for(int j=0;j<stockad.size();j++) {
if(stockad.get(j).item_type.equals("Pants")&&stockad.get(j).item_gender=='M') {
x=x+1;
product pr2=new product(stockad.get(j).item_no,stockad.get(j).item_name,stockad.get(j).item_size,stockad.get(j).item_price);
pr.add(pr2);
}
}
prdt[1]=new ProductList(pr);
pr.clear();
x=-1;
for(int j=0;j<stockad.size();j++) {
if(stockad.get(j).item_type.equals("T-Shirts")&&stockad.get(j).item_gender=='M') {
x=x+1;
product pr3=new product(stockad.get(j).item_no,stockad.get(j).item_name,stockad.get(j).item_size,stockad.get(j).item_price);
pr.add(pr3);
}
}
prdt[2]=new ProductList(pr);
pr.clear();
x=-1;
for(int j=0;j<stockad.size();j++) {
if(stockad.get(j).item_type.equals("Shorts")&&stockad.get(j).item_gender=='M') {
x=x+1;
product pr4=new product(stockad.get(j).item_no,stockad.get(j).item_name,stockad.get(j).item_size,stockad.get(j).item_price);
pr.add(pr4);
}
}
prdt[3]=new ProductList(pr);
pr.clear();
x=-1;
for(int j=0;j<stockad.size();j++) {
if(stockad.get(j).item_type.equals("Shirts")&&stockad.get(j).item_gender=='F') {
x=x+1;
product pr5=new product(stockad.get(j).item_no,stockad.get(j).item_name,stockad.get(j).item_size,stockad.get(j).item_price);
pr.add(pr5);
}
}
prdt[4]=new ProductList(pr);
pr.clear();
x=-1;
for(int j=0;j<stockad.size();j++) {
if(stockad.get(j).item_type.equals("Pants")&&stockad.get(j).item_gender=='F') {
x=x+1;
product pr6=new product(stockad.get(j).item_no,stockad.get(j).item_name,stockad.get(j).item_size,stockad.get(j).item_price);
pr.add(pr6);
}
}
prdt[5]=new ProductList(pr);
pr.clear();
x=-1;
for(int j=0;j<stockad.size();j++) {
if(stockad.get(j).item_type.equals("T-Shirts")&&stockad.get(j).item_gender=='F') {
x=x+1;
product pr7=new product(stockad.get(j).item_no,stockad.get(j).item_name,stockad.get(j).item_size,stockad.get(j).item_price);
pr.add(pr7);
}
}
prdt[6]=new ProductList(pr);
pr.clear();
x=-1;
for(int j=0;j<stockad.size();j++) {
if(stockad.get(j).item_type.equals("Shorts")&&stockad.get(j).item_gender=='F') {
x=x+1;
product pr8=new product(stockad.get(j).item_no,stockad.get(j).item_name,stockad.get(j).item_size,stockad.get(j).item_price);
pr.add(pr8);
}
}
prdt[7]=new ProductList(pr);
pr.clear();
ArrayList<cart> carts = new ArrayList<cart>();
ArrayList<bill> bills = new ArrayList<bill>();
ArrayList<orders> orders= new ArrayList<orders>();
ArrayList<Integer> no= new ArrayList<Integer>();
ArrayList<Integer> sno= new ArrayList<Integer>();
Scanner scan=new Scanner(System.in);
int xyz=0;
while(xyz==0)
{
int login=0;
System.out.println("Welcome to the website");
System.out.println("1. Login 2. SignUp");
int loging = scan.nextInt();
carts.clear();
bills.clear();
if(loging==1||loging==2) {
while(login==0)
{
if(loging==1) {
System.out.println("Username: ");
String name=scan.next();
System.out.println("Password: ");
String pass=scan.next();
for(int i=0;i<=custarr;i++)
{
if(cust[i].username.equals(name)&&cust[i].cpassword.equals(pass))
{
System.out.println("+++ Welcome "+cust[i].customer_name+" +++");
custId=cust[i].customer_Id;
login=3;
break;
}
else {
}
}
if(login==0)
{
System.out.println("Wrong Credentials");
System.out.println("Do you want to try again(y/n)?");
char choice=scan.next().charAt(0);
if(choice=='n'||choice=='N')
{
System.exit(0);
}
}
}
else if(loging==2){
System.out.println("Username: ");
String name=scan.next();
String pass=null;
int passno=1;
while(passno==1)
{
System.out.println("Password: ");
pass=scan.next();
System.out.println("Confirm password: ");
String passcheck=scan.next();
if(pass.equals(passcheck))
{
passno=0;
}
else {
System.out.println("Enter the password again");
}
}
custarr+=1;
//cust[custarr].customer_Id="C"+custarr;
System.out.println("Enter your Mobile number");
String ph=scan.next();
System.out.println("Enter Your name");
String cname=scan.next();
System.out.println("Enter Your Email ID");
String email=scan.next();
System.out.println("Enter your Address");
String add=scan.next();
cust[custarr]=new Customer(name,cname,"c"+custarr,ph,pass,email,add);
custId=cust[custarr].customer_Id;
System.out.println("Welcome "+cust[custarr].customer_name);
login=2;
}
else {
System.out.println("Enter No 1 or 2");
}
}
int menuno=0,genno=0,finalno=0,checkno=0,loopcheck=0,menuchoose=0;
System.out.println("Please select from the given menu:");
superouter:
while(menuno==0)
{
genno=0;
finalno=0;
checkno=0;
System.out.println("1. Product List");
System.out.println("2. Cart");
System.out.println("3. Orders");
System.out.println("4. Logout");
menuchoose=scan.nextInt();
outer:
if(menuchoose==1)
{
System.out.println("Which section you want to cruise into?(1/2)");
while(genno==0)
{int catno=0,prno=0;
System.out.println("1. Male");
System.out.println("2. Female");
System.out.println("3. Back");
int genchoose=scan.nextInt();
if(genchoose==1)
{
int close=0;
while(close==0) {
System.out.println("Choose from the Categories:(1/2/3/4)");
System.out.println("1. Shirts");
System.out.println("2. Pants");
System.out.println("3. T-Shirts");
System.out.println("4. Shorts");
System.out.println("5. Back");
int catchoose=scan.nextInt();
if(catchoose==1) {///PANTS FOR MEN/// -1
for(int i=0;i<prdt[0].prdtt.size();i++) {
no.add(prdt[0].prdtt.get(i).prdt_id);
System.out.println(i+". "+prdt[0].prdtt.get(i).prdt_name+" - "+prdt[0].prdtt.get(i).price);
checkno=0;
}
System.out.println("Do u want to 1. Filter(acc to price) 2. Sort(price) or 3.To continue");
int aaa=scan.nextInt();
if(aaa==1)//Price Filter
{
System.out.println("Enter max price:");
int max=scan.nextInt();
for(int i=0;i<prdt[0].prdtt.size();i++)
{
if(prdt[0].prdtt.get(i).price<max)
System.out.println(i+". "+prdt[0].prdtt.get(i).prdt_name+" - "+prdt[0].prdtt.get(i).price);
}
}
else if(aaa==2) {//SIZE sort
pr = new ArrayList<product>(prdt[0].prdtt);
Collections.sort(pr);
int q=-1;
for (product str : pr) {
q+=1;;
sno.add(prdt[0].prdtt.get(q).prdt_id);
System.out.println(q);
System.out.println(str);
checkno=1;
}
}
else if(aaa==3) {//Back
}
else
{
System.out.println("Please enter digits 1 or 2");
}
System.out.println("Enter the digit of the product: ");
prno=scan.nextInt();
int ind=0,val=0;
for(int i=0;i<prdt[0].prdtt.size();i++) {
if(prno==i) {
cart c1= new cart();
cart c2= new cart();
if(checkno==0) {
ind=no.get(i);
for(int l=0;l<prdt[0].prdtt.size();l++)
if(prdt[0].prdtt.get(l).prdt_id==ind)
val=l;
c1.insert(prdt[0].prdtt.get(val).price,prdt[0].prdtt.get(val).prdt_id);
carts.add(c1);}
if(checkno==1) {
ind=sno.get(i);
for(int l=0;l<prdt[0].prdtt.size();l++)
if(prdt[1].prdtt.get(l).prdt_id==ind)
val=l;
c2.insert(prdt[0].prdtt.get(val).price,prdt[0].prdtt.get(val).prdt_id);
carts.add(c2);}
System.out.println("The product number "+val+ " has been added to the cart.");
System.out.println("Continue shopping (y/n)");
char c =scan.next().charAt(0);
if(c=='Y'||c=='y')
{
;
}
else if (c=='N'||c=='n')
{
loopcheck=1;
break outer;
}
}
}
pr.clear();
no.clear();
sno.clear();
}
else if(catchoose==2) { ///PANTS FOR MEN/// -1
for(int i=0;i<prdt[1].prdtt.size();i++) {
no.add(prdt[1].prdtt.get(i).prdt_id);
System.out.println(i+". "+prdt[1].prdtt.get(i).prdt_name+" - "+prdt[1].prdtt.get(i).price);
checkno=0;
}
System.out.println("Do u want to 1. Filter(acc to price) 2. Sort(price) or 3.To continue");
int aaa=scan.nextInt();
if(aaa==1)//Price Filter
{
System.out.println("Enter max price:");
int max=scan.nextInt();
for(int i=0;i<prdt[1].prdtt.size();i++)
{
if(prdt[1].prdtt.get(i).price<max)
System.out.println(i+". "+prdt[1].prdtt.get(i).prdt_name+" - "+prdt[1].prdtt.get(i).price);
}
}
else if(aaa==2) {//SIZE sort
pr = new ArrayList<product>(prdt[1].prdtt);
Collections.sort(pr);
int q=-1;
for (product str : pr) {
q+=1;;
sno.add(prdt[1].prdtt.get(q).prdt_id);
System.out.println(q);
System.out.println(str);
checkno=1;
}
}
else if(aaa==3) {//Back
}
else
{
System.out.println("Please enter digits 1 or 2");
}
System.out.println("Enter the digit of the product: ");
prno=scan.nextInt();
int ind=0,val=0;
for(int i=0;i<prdt[1].prdtt.size();i++) {
if(prno==i) {
cart c1= new cart();
cart c2= new cart();
if(checkno==0) {
ind=no.get(i);
for(int l=0;l<prdt[1].prdtt.size();l++)
if(prdt[1].prdtt.get(l).prdt_id==ind)
val=l;
c1.insert(prdt[1].prdtt.get(val).price,prdt[1].prdtt.get(val).prdt_id);
carts.add(c1);}
if(checkno==1) {
ind=sno.get(i);
for(int l=0;l<prdt[1].prdtt.size();l++)
if(prdt[1].prdtt.get(l).prdt_id==ind)
val=l;
c2.insert(prdt[1].prdtt.get(val).price,prdt[1].prdtt.get(val).prdt_id);
carts.add(c2);}
System.out.println("The product number "+val+ " has been added to the cart.");
System.out.println("Continue shopping (y/n)");
char c =scan.next().charAt(0);
if(c=='Y'||c=='y')
{
;
}
else if (c=='N'||c=='n')
{
loopcheck=1;
break outer;
}
}
}
pr.clear();
no.clear();
sno.clear();
}
else if(catchoose==3) { ///T-shirts for MEN///
System.out.println("T-Shirts:");
for(int i=0;i<prdt[2].prdtt.size();i++) {
no.add(prdt[2].prdtt.get(i).prdt_id);
System.out.println(i+". "+prdt[2].prdtt.get(i).prdt_name+" - "+prdt[2].prdtt.get(i).price);
checkno=0;
}
System.out.println("Do u want to 1. Filter(acc to price) 2. Sort(price) or 3.To continue");
int aaa=scan.nextInt();
if(aaa==1)
{
System.out.println("Enter max price:");
int max=scan.nextInt();
for(int i=0;i<prdt[2].prdtt.size();i++)
{
if(prdt[2].prdtt.get(i).price<max)
System.out.println(i+". "+prdt[2].prdtt.get(i).prdt_name+" - "+prdt[2].prdtt.get(i).price);
}
}
else if(aaa==2) {
pr = new ArrayList<product>(prdt[2].prdtt);
Collections.sort(pr);
int q=-1;
for (product str : pr) {
q+=1;;
sno.add(prdt[2].prdtt.get(q).prdt_id);
System.out.println(q);
System.out.println(str);
checkno=1;
}
}
else if(aaa==3) {
}
else
{
System.out.println("Please enter digits 1 or 2");
}
System.out.println("Enter the digit of the product: ");
prno=scan.nextInt();
int ind=0,val=0;
for(int i=0;i<prdt[2].prdtt.size();i++) {
if(prno==i) {
cart c1= new cart();
cart c2= new cart();
if(checkno==0) {
ind=no.get(i);
for(int l=0;l<prdt[2].prdtt.size();l++)
if(prdt[2].prdtt.get(l).prdt_id==ind)
val=l;
c1.insert(prdt[2].prdtt.get(val).price,prdt[2].prdtt.get(val).prdt_id);
carts.add(c1);}
if(checkno==1) {
ind=sno.get(i);
for(int l=0;l<prdt[2].prdtt.size();l++)
if(prdt[2].prdtt.get(l).prdt_id==ind)
val=l;
c2.insert(prdt[2].prdtt.get(val).price,prdt[2].prdtt.get(val).prdt_id);
carts.add(c2);}
System.out.println("The product number "+val+ " has been added to the cart.");
System.out.println("Continue shopping (y/n)");
char c =scan.next().charAt(0);
if(c=='Y'||c=='y')
{
;
}
else if (c=='N'||c=='n')
{
loopcheck=1;
break outer;
}
}
}
pr.clear();
no.clear();
sno.clear();
}
else if(catchoose==4) {///Shorts for men///
System.out.println("Shorts");
for(int i=0;i<prdt[3].prdtt.size();i++) {
no.add(prdt[3].prdtt.get(i).prdt_id);
System.out.println(i+". "+prdt[3].prdtt.get(i).prdt_name+" - "+prdt[3].prdtt.get(i).price);
checkno=0;
}
System.out.println("Do u want to 1. Filter(acc to price) 2. Sort(price) or 3.To continue");
int aaa=scan.nextInt();
if(aaa==1)
{
System.out.println("Enter max price:");
int max=scan.nextInt();
for(int i=0;i<prdt[3].prdtt.size();i++)
{
if(prdt[3].prdtt.get(i).price<max)
System.out.println(i+". "+prdt[3].prdtt.get(i).prdt_name+" - "+prdt[3].prdtt.get(i).price);
}
}
else if(aaa==2) {
pr = new ArrayList<product>(prdt[3].prdtt);
Collections.sort(pr);
int q=-1;
for (product str : pr) {
q+=1;;
sno.add(prdt[3].prdtt.get(q).prdt_id);
System.out.println(q);
System.out.println(str);