-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy-project.cpp
928 lines (900 loc) · 20.6 KB
/
my-project.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
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
#include<iostream>
#include<vector>
#include<string>
#include<fstream>
#include<time.h>
using namespace std;
class Stuff
{
public:
Stuff(string Title, int Price, int id, int Stock);
int getId()
{
return ID;
}
int getPrice()
{
return price;
}
int getStock()
{
return stock;
}
string getTitle()
{
return title;
}
void update();
void purchase(int count)
{
stock -= count;
}
private:
int ID, price, stock;
string title;
};
Stuff::Stuff(string Title = "", int Price = 0, int id = 1, int Stock = 1)
{
title = Title;
price = Price;
ID = id;
stock = Stock;
}
class Client
{
public:
Client(string Name, int phone);
string getName()
{
return name;
}
int getPhone()
{
return phoneNumber;
}
void update();
protected:
string name;
int phoneNumber;
};
Client::Client(string Name = "", int phone = 01)
{
name = Name;
phoneNumber = phone;
}
class SpecialClient : public Client
{
public:
SpecialClient(string Name, int phone) :
Client(Name, phone)
{
}
void update();
};
// add functions
Stuff addStuff()
{
int price, id, stock;
string title;
cout << "enter stuff title: ";
cin >> title;
cout << "enter " << title << " price: ";
cin >> price;
cout << "enter " << title << " id: ";
cin >> id;
cout << "enter number of " << title << "'s you want to add: ";
cin >> stock;
return Stuff(title, price, id, stock);
}
Client addClient()
{
int phone;
string name;
cout << "enter client name: ";
cin >> name;
cout << "enter client phone number: ";
cin >> phone;
return Client(name, phone);
}
SpecialClient addSpecial()
{
int phone;
string name;
cout << "enter client name: ";
cin >> name;
cout << "enter client phone number: ";
cin >> phone;
return SpecialClient(name, phone);
}
// update functions
void Stuff::update()
{
int field;
cout << "which field you want to update: \n";
cout << "\t1:update title\n";
cout << "\t2:update price\n";
cout << "\t3:update stock\n";
cout << "\t4:update id\n";
cout << "\t5:update price and stock\n";
cin >> field;
switch (field)
{
case 1:
cout << "enter new title: ";
cin >> title;
break;
case 2:
cout << "enter new price: ";
cin >> price;
break;
case 3:
cout << "enter new stock: ";
cin >> stock;
break;
case 4:
cout << "enter new id: ";
cin >> ID;
break;
case 5:
cout << "enter new price: ";
cin >> price;
cout << "enter new stock: ";
cin >> stock;
break;
default:
cout << "wrong choice!!\n";
cout << "exit without any update\n";
}
}
void Client::update()
{
int field;
cout << "which field you want to update: \n";
cout << "\t1:update name\n";
cout << "\t2:update phone number\n";
cout << "\t3:update name and phone, both\n";
cin >> field;
switch (field)
{
case 1:
cout << "enter new name: ";
cin >> name;
break;
case 2:
cout << "enter new phone number: ";
cin >> phoneNumber;
break;
case 3:
cout << "enter new name: ";
cin >> name;
cout << "enter new phone number: ";
cin >> phoneNumber;
break;
default:
cout << "wrong choice!!\n";
cout << "exit without any update\n";
break;
}
}
void SpecialClient::update()
{
int field;
cout << "which field you want to update: \n";
cout << "\t1:update name\n";
cout << "\t2:update phone number\n";
cout << "\t3:update name and phone, both\n";
cin >> field;
switch (field)
{
case 1:
cout << "enter new name: ";
cin >> name;
break;
case 2:
cout << "enter new phone number: ";
cin >> phoneNumber;
break;
case 3:
cout << "enter new name: ";
cin >> name;
cout << "enter new phone number: ";
cin >> phoneNumber;
break;
default:
cout << "wrong choice!!\n";
cout << "exit without any update\n";
break;
}
}
class Purchase
{
public:
Purchase(Client client, vector<Stuff> stuff, int purchaseNo, int price);
string getClient()
{
return client.getName();
}
vector<Stuff> getStuff()
{
return stuffs;
}
int getNo()
{
return purchaseNO;
}
int getPrice()
{
return price;
}
protected:
vector<Stuff> stuffs;
Client client;
int purchaseNO, price;
};
Purchase::Purchase(Client client, vector<Stuff> stuff, int purchaseNo, int price)
{
this->stuffs = stuff;
this->client = client;
purchaseNO = purchaseNo;
this->price = price;
}
class SpecialPurchase : public Purchase
{
public:
SpecialPurchase(SpecialClient special, vector<Stuff> stuff, int purchaseNo, int price) :
Purchase(special, stuff, purchaseNo, price)
{
}
};
class Shop
{
public:
Shop(vector<Stuff> stuff, vector<Client> client, vector<SpecialClient> special,
vector<Purchase> purchase, vector<SpecialPurchase> specialPurchase);
void remove(int index);
void clientPurchase(Client client);
void specialPurchase(SpecialClient special);
void add();
void update();
void userRemove();
void purchase();
void report();
vector<Stuff> getStuff()
{
return stuffs;
}
vector<Client> getClient()
{
return clients;
}
vector<SpecialClient> getSpecial()
{
return specials;
}
vector<Purchase> getPurchase()
{
return purchases;
}
vector<SpecialPurchase> getSpecialPurchase()
{
return specialPurchases;
}
fstream stuffFile, clientFile, specialFile, purchaseFile;
private:
vector<Stuff> stuffs;
vector<Client> clients;
vector<SpecialClient> specials;
vector<Purchase> purchases;
vector<SpecialPurchase> specialPurchases;
};
Shop::Shop(vector<Stuff> stuff, vector<Client> client, vector<SpecialClient> special,
vector<Purchase> purchase =
{ }, vector<SpecialPurchase> specialPurchase =
{ })
{
stuffs = stuff;
clients = client;
specials = special;
purchases = purchase;
specialPurchases = specialPurchase;
}
void Shop::remove(int index)
{
stuffs[index] = stuffs[stuffs.size() - 1];
stuffs.pop_back();
}
void Shop::clientPurchase(Client client)
{
int check = 1, choose, count;
int total = 0;
vector<Stuff> stuff;
if (stuffs.size() >= 1)
{
while (check)
{
for (int i = 0; i < stuffs.size(); i++)
{
cout << i + 1 << ": " << "title: " << stuffs[i].getTitle() << "\tprice: "
<< stuffs[i].getPrice() << "\tstock: " << stuffs[i].getStock() << endl;
}
cout << "enter your choose: \n";
if(check%3==1)
{
cout << "remember that you can exit from purchasing by entering number '0'!!\n";
}
check++;
cin >> choose;
if (choose == 0)
{
check = 0;
break;
}
if (choose <= stuffs.size() || choose > 0)
{
cout << "enter number of " << stuffs[choose - 1].getTitle()
<< " you want to purchase: ";
cin >> count;
total += stuffs[choose - 1].getPrice() * count;
if (count > stuffs[choose - 1].getStock())
{
cout << "not enough " << stuffs[choose - 1].getTitle() << "'s to purchase\n";
}
else
{
if (count < stuffs[choose - 1].getStock())
{
stuffs[choose - 1].purchase(count);
}
else
{
remove(choose - 1);
}
Stuff last = stuffs[choose - 1];
last = Stuff(last.getTitle(), last.getPrice(), last.getId(), count);
stuff.push_back(last);
}
}
}
cout << "you have to pay " << total << "$\n";
srand(time(0));
int purchaseNo = rand() % (100000) + 1;
Purchase purchase(client, stuff, purchaseNo, total);
purchases.push_back(purchase);
purchaseFile << "NO: " << purchase.getNo() << " - " << "stuffs: ";
for (int i = 0; i < purchase.getStuff().size(); i++)
{
Stuff writing = purchase.getStuff()[i];
purchaseFile << writing.getTitle() << ":" << writing.getStock() << " ";
}
purchaseFile << "- paid: " << purchase.getPrice() << " - " << "made by: "
<< purchase.getClient() << endl;
}
else
cout << "no stuff to purchase!!\n";
}
void Shop::specialPurchase(SpecialClient special)
{
int check = 1, choose, count;
int total = 0;
vector<Stuff> stuff;
if (stuffs.size() >= 1)
{
while (check)
{
for (int i = 0; i < stuffs.size(); i++)
{
cout << i + 1 << ": " << "title: " << stuffs[i].getTitle() << "\tprice: "
<< stuffs[i].getPrice() << "\tstock: " << stuffs[i].getStock() << endl;
}
cout << "enter your choose: ";
if(check%3==1)
{
cout << "remember that you can exit from purchasing by entering number '0'!!\n";
}
check++;
cin >> choose;
if (choose == 0)
{
check = 0;
break;
}
if (choose <= stuffs.size() || choose > 0)
{
cout << "enter number of " << stuffs[choose - 1].getTitle()
<< " you want to purchase: ";
cin >> count;
total += stuffs[choose - 1].getPrice() * count;
if (count > stuffs[choose - 1].getStock())
{
cout << "not enough " << stuffs[choose - 1].getTitle() << "'s to purchase\n";
}
else
{
if (count < stuffs[choose - 1].getStock())
{
stuffs[choose - 1].purchase(count);
}
else
{
remove(choose - 1);
}
Stuff last = stuffs[choose - 1];
last = Stuff(last.getTitle(), last.getPrice(), last.getId(), count);
stuff.push_back(last);
}
}
}
cout << "total purchase is: " << total << endl;
total = total * 0.8;
cout << "but because you are one of our special clients ,\n";
cout << "you have to pay " << total << "$ !!!\n";
srand(time(0));
int purchaseNo = rand() % (100000) + 1;
SpecialPurchase purchase(special, stuff, purchaseNo, total);
specialPurchases.push_back(purchase);
purchaseFile << "NO: " << purchase.getNo() << " - " << "stuffs: ";
for (int i = 0; i < purchase.getStuff().size(); i++)
{
Stuff writing = purchase.getStuff()[i];
purchaseFile << writing.getTitle() << ":" << writing.getStock() << " ";
}
purchaseFile << "- paid: " << purchase.getPrice() << " - " << "made by: "
<< purchase.getClient() << endl;
}
else
cout << "no stuff to purchase!!\n";
}
void Shop::add()
{
int choose;
cout << "choose an option below: \n";
cout << "\t1:add a stuff \n";
cout << "\t2:add a client \n";
cout << "\t3:add an special client \n";
cout << "\t4:cancel operation\n";
cin >> choose;
system("cls");
switch (choose)
{
case 1:
{
stuffs.push_back(addStuff());
Stuff last = stuffs[stuffs.size() - 1];
stuffFile << "title: " << last.getTitle() << "\tprice: " << last.getPrice() << "\tid: "
<< last.getId() << "\tstock: " << last.getStock() << "\tadded" << endl;
}
break;
case 2:
{
clients.push_back(addClient());
Client last = clients[clients.size() - 1];
clientFile << "name: " << last.getName() << "\tphone: " << last.getPhone()
<< "\tadded\n";
}
break;
case 3:
{
specials.push_back(addSpecial());
SpecialClient last = specials[specials.size() - 1];
specialFile << "name: " << last.getName() << "\tphone: " << last.getPhone()
<< "\tadded\n";
}
break;
case 4:
break;
default:
cout << "wrong choice!!\n";
cout << "try again: \n";
add();
break;
}
}
void Shop::update()
{
int option, choose;
cout << "choose an option below: \n";
cout << "\t1:update a stuff\n";
cout << "\t2:update a client\n";
cout << "\t3:update an special client\n";
cout << "\t4:cancel operation\n";
cin >> option;
system("cls");
switch (option)
{
case 1:
if (stuffs.size() >= 1)
{
for (int i = 0; i < stuffs.size(); i++)
{
cout << i + 1 << ": " << "title: " << stuffs[i].getTitle() << "\tprice: "
<< stuffs[i].getPrice() << "\tstock: " << stuffs[i].getStock() << endl;
}
cout << "\nenter your choose: ";
cin >> choose;
if (choose <= stuffs.size())
{
Stuff update = stuffs[choose - 1];
stuffFile << "title: " << update.getTitle() << "\tprice: " << update.getPrice()
<< "\tid: " << update.getId() << "\tStock: " << update.getStock()
<< "\tUpdated to :\n";
stuffs[choose - 1].update();
update = stuffs[choose - 1];
stuffFile << '\t' << update.getTitle() << '\t' << update.getPrice() << '\t'
<< update.getId() << '\t' << update.getStock() << endl;
}
}
else
{
cout << "no stuff to update!!\n";
}
break;
case 2:
if (clients.size() >= 1)
{
for (int i = 0; i < clients.size(); i++)
{
cout << i + 1 << ": " << "name: " << clients[i].getName() << "\tphone: "
<< clients[i].getPhone() << endl;
}
cout << "\nenter your choose: ";
cin >> choose;
if (choose <= clients.size())
{
Client update = clients[choose - 1];
clientFile << "name: " << update.getName() << "\tphone: " << update.getPhone()
<< "\tUpdated to:\n";
clients[choose - 1].update();
update = clients[choose - 1];
clientFile << '\t' << update.getName() << '\t' << update.getPhone() << endl;
}
}
else
{
cout << "no client to update!!\n";
}
break;
case 3:
if (specials.size() >= 1)
{
for (int i = 0; i < specials.size(); i++)
{
cout << i + 1 << ": " << "name: " << specials[i].getName() << "\tphone: "
<< specials[i].getPhone() << endl;
}
cout << "\nenter your choose: ";
cin >> choose;
if (choose <= specials.size())
{
specials[choose - 1].update();
}
}
else
{
cout << "no special client to update!!\n";
}
break;
case 4:
break;
default:
cout << "wrong choice!!\n";
cout << "try again\n";
update();
break;
}
}
void Shop::userRemove()
{
int option, choose;
cout << "choose an option below: \n";
cout << "\t1:remove a stuff\n";
cout << "\t2:remove a client\n";
cout << "\t3:remove an special client\n";
cin >> option;
system("cls");
switch (option)
{
case 1:
if (stuffs.size() >= 1)
{
for (int i = 0; i < stuffs.size(); i++)
{
cout << i + 1 << ": " << "title: " << stuffs[i].getTitle() << "\tprice: "
<< stuffs[i].getPrice() << "\tstock: " << stuffs[i].getStock() << endl;
}
cout << "\nenter your choose: ";
cin >> choose;
if (choose <= stuffs.size())
{
if (choose > 0)
{
Stuff del = stuffs[choose - 1];
stuffs[choose - 1] = stuffs[stuffs.size() - 1];
stuffs.pop_back();
stuffFile << "title: " << del.getTitle() << "\tprice: " << del.getPrice()
<< "\tid: " << del.getId() << '\t' << del.getStock()
<< "\tremoved" << endl;
}
}
}
else
{
cout << "no stuff to remove!!\n";
}
break;
case 2:
if (clients.size() >= 1)
{
for (int i = 0; i < clients.size(); i++)
{
cout << i + 1 << ": " << "name: " << clients[i].getName() << "\tphone: "
<< clients[i].getPhone() << endl;
}
cout << "\nenter your choose: ";
cin >> choose;
if (choose <= clients.size())
{
Client del = clients[choose - 1];
clients[choose - 1] = clients[clients.size() - 1];
clients.pop_back();
clientFile << "name: " << del.getName() << "\tphone: " << del.getPhone()
<< "\tremoved" << endl;
}
}
else
{
cout << "no client to remove!!\n";
}
break;
case 3:
if (specials.size() >= 1)
{
for (int i = 0; i < specials.size(); i++)
{
cout << i + 1 << ": " << "name: " << specials[i].getName() << "\tphone: "
<< specials[i].getPhone() << endl;
}
cout << "\nenter your choose: ";
cin >> choose;
if (choose <= specials.size())
{
SpecialClient del = specials[choose - 1];
specials[choose - 1] = specials[specials.size() - 1];
specials.pop_back();
specialFile << "name: " << del.getName() << "\tphone: " << del.getPhone()
<< "\tremoved" << endl;
}
}
else
{
cout << "no special client to remove!!\n";
}
break;
case 4:
break;
default:
cout << "wrong choice!!\n";
cout << "try again\n";
userRemove();
break;
}
}
void Shop::purchase()
{
int option, choose;
cout << "choose an option below: \n";
cout << "\t1:purchase by a client\n";
cout << "\t2:purchase by an special client\n";
cout << "\t3:cancel operation\n";
cin >> option;
system("cls");
switch (option)
{
case 1:
if (clients.size() >= 1)
{
for (int i = 0; i < clients.size(); i++)
{
cout << i + 1 << ": " << "name: " << clients[i].getName() << "\tphone: "
<< clients[i].getPhone() << endl;
}
cout << "enter your choose: ";
cin >> choose;
if (choose >= clients.size())
{
clientPurchase(clients[choose - 1]);
}
}
else
{
cout << "your shop has no clients!!\n";
}
break;
case 2:
if (specials.size() >= 1)
{
for (int i = 0; i < specials.size(); i++)
{
cout << i + 1 << ": " << "name: " << specials[i].getName() << "\tphone: "
<< specials[i].getPhone() << endl;
}
cout << "enter your choose: ";
cin >> choose;
if (choose >= specials.size())
{
specialPurchase(specials[choose - 1]);
}
}
else
{
cout << "your shop has no special clients!!\n";
}
break;
case 3:
break;
default:
cout << "wrong choice!!\n";
cout << "try again\n";
purchase();
break;
}
}
void Shop::report()
{
int choose;
cout << "choose an option below: \n";
cout << "\t1:view all stuffs\n";
cout << "\t2:view all clients\n";
cout << "\t3:view shopping list\n";
cout << "\t4:view sales list\n";
cout << "\t5:cancel operation\n";
cin >> choose;
system("cls");
switch (choose)
{
case 1:
for (int i = 0; i < stuffs.size(); i++)
{
cout << i + 1 << ": " << "id: " << stuffs[i].getId() << "\ttitle: "
<< stuffs[i].getTitle() << "\tprice: " << stuffs[i].getPrice()
<< "\tstock: " << stuffs[i].getStock() << endl;
}
break;
case 2:
if (clients.size() >= 1)
{
cout << "all clients: \n";
for (int i = 0; i < clients.size(); i++)
{
cout << i + 1 << ": " << "name: " << clients[i].getName() << "\tphone: "
<< clients[i].getPhone() << endl;
}
}
else
cout << "no clients to show!!\n";
if (specials.size() >= 1)
{
cout << "all special clients: \n";
for (int i = 0; i < specials.size(); i++)
{
cout << i + 1 << ": " << "name: " << specials[i].getName() << "\tphone: "
<< specials[i].getPhone() << endl;
}
}
else
cout << "no special client to show!!\n";
break;
case 3:
if (purchases.size() >= 1)
{
cout << "all purchases by clients: \n";
for (int i = 0; i < purchases.size(); i++)
{
cout <<'\t'<< i + 1 << ": " << "purchase no: " << purchases[i].getNo() << "\tclient: "
<< purchases[i].getClient() << "\tprice: " << purchases[i].getPrice()
<< endl;
}
}
else
cout << "no purchase made by clients!!\n";
if (specialPurchases.size() >= 1)
{
cout << "\nall purchases by special clients: \n";
for (int i = 0; i < specialPurchases.size(); i++)
{
cout << '\t'<<i + 1 << ": " << "purchase no: " << specialPurchases[i].getNo()
<< "\tclient: " << specialPurchases[i].getClient() << "\tprice: "
<< specialPurchases[i].getPrice() << endl;
}
}
else
cout << "no purchase made by special clients!!\n";
break;
case 4:
{
int k = 1;
if (purchases.size() >= 1 || specialPurchases.size() >= 1)
{
for (int i = 0; i < purchases.size(); i++)
{
vector<Stuff> stuff = purchases[i].getStuff();
for (int j = 0; j < stuff.size(); j++)
{
cout << k << ": " << "title: " << stuff[j].getTitle() << "\tid: "
<< stuff[j].getId() << "\tcount: " << stuff[j].getStock() << endl;
k++;
}
}
for (int i = 0; i < specialPurchases.size(); i++)
{
vector<Stuff> stuff = specialPurchases[i].getStuff();
for (int j = 0; j < stuff.size(); j++)
{
cout << k << ": " << "title: " << stuff[j].getTitle() << "\tid: "
<< stuff[j].getId() << "\tcount: " << stuff[j].getStock() << endl;
k++;
}
}
}
}
break;
case 5:
break;
default:
cout << "wrong choice!!\n";
cout << "try again\n";
report();
break;
}
}
int main()
{
int choose, check = 1;
vector<Stuff> stuffs;
vector<Client> clients;
vector<SpecialClient> specials;
Shop shop(stuffs, clients, specials);
shop.stuffFile.open("stuff.txt", ios::out);
shop.clientFile.open("client.txt", ios::out);
shop.specialFile.open("special.txt", ios::out);
shop.purchaseFile.open("purchaseFile.txt", ios::out);
int stuffSize = 0, clientSize = 0, specialSize = 0, purchaseSize = 0, specialPurchaseSize = 0;
while (check)
{
cout << "choose an option below: \n";
cout << "\t1:add an item\n";
cout << "\t2:update an item\n";
cout << "\t3:remove an item\n";
cout << "\t4:make a purchase\n";
cout << "\t5:shop reports\n";
cout << "\t6:exit\n";
cin >> choose;
system("cls");
switch (choose)
{
case 1:
shop.add();
break;
case 2:
shop.update();
break;
case 3:
shop.userRemove();
break;
case 4:
shop.purchase();
break;
case 5:
shop.report();
break;
case 6:
check = 0;
break;
default:
cout << "ERR!!\n";
cout << "\tplease choose a correct option\n";
break;
}
system("cls");
}
return 0;
}