-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.c
2254 lines (1751 loc) · 51.9 KB
/
project.c
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
#include "selfStructs.h"
#include "struct.h" //Our Student DATA are stored there
int stringCmpID(Node* current,char useridlogin[]);
int stringCmpPass(Node* current,char passwordlogin[]);
void print_list(Node *head);
void main();
void print_listMenu();
void reserveFood();
void ChargeMenu(char loginuserid[]);
void ChangePassAdmin()
{
system("cls");
char NewPass[20];
char userID[20];
printf("\nAll Users :\n------------\n\n");
Node* c1 = head;
int counter = 1;
while (c1 != NULL)
{
printf("User ID %d: %s\n",counter,c1->user_id);
counter++;
c1 = c1->next;
}
printf("\n------------\n");
printf("Enter a User ID\n");
scanf("%s",userID);
Node* current = head;
while (current != NULL)
{
if (stringCmpID(current,userID)) //current->user_id == loginuserid
{
printf("Enter Your New Password :\n");
scanf("%s",NewPass);
printf("\n\nUser \"%s\" Password Changed to \"%s\"\n",current->user_id,NewPass);
Sleep(2000);
if (strlen(current->password)<strlen(NewPass))
{
for (int i = strlen(current->password) ; i <= strlen(NewPass); i++)
{
current->password[i] = '\0';
}
}
else if(strlen(current->password)>strlen(NewPass))
{
for (int i = strlen(NewPass); i < strlen(current->password); i++)
{
current->password[i] = '\0';
}
}
strncpy(current->password,NewPass,strlen(NewPass));
Sleep(1500);
system("cls");
return;
}
current = current->next;
}
printf("User Does Not Exist");
Sleep(2000);
return;
}
void ChangePass(char loginuserid[]) //Can Change Pass by giving the old pass and new pass
{
char CheckPass[20];
char NewPass[20];
system("cls");
printf("Your Current Password :\n");
scanf("%s",CheckPass);
Node* current = head;
while (current != NULL)
{
if (stringCmpPass(current,CheckPass)) //current->user_id == loginuserid
{
printf("Enter Your New Password :\n");
scanf("%s",NewPass);
printf("\n\nYour Password Changed to \"%s\"\n",NewPass);
Sleep(2000);
if (strlen(current->password)<strlen(NewPass))
{
for (int i = strlen(current->password) ; i <= strlen(NewPass); i++)
{
current->password[i] = '\0';
}
}
else if(strlen(current->password)>strlen(NewPass))
{
for (int i = strlen(NewPass); i < strlen(current->password); i++)
{
current->password[i] = '\0';
}
}
strncpy(current->password,NewPass,strlen(NewPass));
Sleep(1500);
system("cls");
return;
}
current = current->next;
}
printf("Wrong Pass !\n");
Sleep(2000);
system("cls");
return;
}
struct tm* TimeHandle() //a pointer to our local time structure
{
time_t now = time(NULL);
char *string_now = ctime(&now);
struct tm *timePointer =localtime(&now);
return timePointer;
}
void showCurrentTime() //when called anywhere can show you the time
{
headtime = TimeHandle(); //use this line when you want to change the time
if(godtime == 0) //halate aadi godtime 0 e
{
printf("%d:",headtime->tm_hour);
printf("%d\n",headtime->tm_min);
printf("%d/",headtime->tm_year+1900);
printf("%d/",headtime->tm_mon+1);
printf("%d\n",headtime->tm_mday);
}
else if(godtime == 1) //harja time o taghir midim godtime 1 mishe
{
printf("%d:",changeHour);
printf("%d\n",changeMinute);
printf("%d/",changeYear);
printf("%d/",changeMonth);
printf("%d\n",changeDay);
}
}
void ChangeTime()
{
system("cls");
showCurrentTime();
printf("\n-------\n");
printf("Enter The Desired Time (HH:MM YY/MM/DD):\n");
scanf("%d:%d %d/%d/%d",&changeHour,&changeMinute,&changeYear,&changeMonth,&changeDay);
godtime = 1;
printf("Time Set to :\n");
showCurrentTime();
//
// printf("Time Back to:\n");
// godtime = 0;
// showCurrentTime();
return;
}
Self* newSelf(char SelfName[],char SelfLocation[],int SelfCapacity,char SelfType[],char SelfMeals[],int Selfid,
int lunchHour1, int lunchMinute1,int dinnerHour1,int dinnerMinute1
,int lunchHour2,int lunchMinute2,int dinnerHour2,int dinnerMinute2)
{
Self*outself =(Self*) malloc(sizeof(Self));
strcpy(outself->SelfName,SelfName);
strcpy(outself->SelfLocation,SelfLocation);
strcpy(outself->SelfType,SelfType);
strcpy(outself->SelfMeals,SelfMeals);
outself->SelfCapacity = SelfCapacity;
outself->Selfid = Selfid;
outself->foods;
for (int i = 0; i < 5; i++)
{
outself->foodCount[i] = 0;
}
// outself->foodCount[] = 0;
outself->lunchHour1 = lunchHour1;
outself->lunchMinute1 = lunchMinute1;
outself->dinnerHour1 = dinnerHour1;
outself->dinnerMinute1 = dinnerMinute1;
outself->mealplandefined = 0;
outself->lunchHour2 = lunchHour2;
outself->lunchMinute2 = lunchMinute2;
outself->dinnerHour2 = dinnerHour2;
outself->dinnerMinute2 = dinnerMinute2;
outself->selfyear = 0;
outself->selfmonth = 0;
outself->selfday = 0;
outself->next = NULL;
return outself;
}
food *new_food(int foodID,char foodName[],int foodtype,double foodprice)
{
food *output =(food *) malloc(sizeof(food));
output->foodID = foodID;
output->foodtype = foodtype;
output->foodPrice = foodprice;
// output->foodCount = 0;
strcpy(output->nameFood,foodName);
output->next = NULL;
return output;
}
void add_food(food *headfood, food *new_food)
{
food *current = headfood;
while (current->next != NULL)
{
current = current->next;
}
current->next = new_food;
}
void add_Self(Self *selfhead, Self *new_self) //be akharesh ezafe mishe //struct sakhte shode va head ro migire
{
Self *currentself = selfhead;
while (currentself->next != NULL)
{
currentself = currentself->next;
}
currentself->next = new_self;
}
void readFilefunc() //test case part
{
//final_test_case_no_invalid_input
FILE* fppointer = fopen("test8.txt","r");
int casenumb;
char casecomm[20];
// while (feof(fppointer))
// {
// }
fscanf(fppointer,"%[^#]%d%[^#]%s",&casenumb,casecomm);
printf("%d",casenumb);
printf("%s",casecomm);
Sleep(5000);
return;
}
void transmit() //shows all the datas of charges
{
system("cls");
Node* c1 = head;
if (c1 ==NULL)
{
printf("No User Stored");
Sleep(2000);
system("cls");
return;
}
char ID[20];
printf("\nAll Users :\n");
int counter = 1;
while (c1 != NULL)
{
printf("User %d: %s\n",counter,c1->user_id);
counter++;
c1 = c1->next;
}
printf("Enter a User ID :\n");
scanf("%s",ID);
system("cls");
Node* current = head;
while (current != NULL)
{
if (stringCmpID(current,ID))
{
printf("Charge :%d\n",current->charge);
printf("Currently Reserved Self: %d\n\n\n",current->self_reserveId);
printf("Currently Reserved Food: %d\n\n\n",current->foodoption);
Sleep(5000);
}
current = current->next;
}
system("cls");
}
void showAdminMenu()
{
system("cls");
showCurrentTime();
printf("\033[1;32m");
printf("---------\n");
printf("\033[0m");
printf("Registered Counter = %d\n",RegisterCounter);
printf("\n1.Show All Registered Data\n2.add news\n3.User's Transactions\n4.Logout\n");
printf("5.Change User's Pass\n6.Change Time\n7.Charge Student Account\n8.Define Self\n9.Define Food\n10.Define Food Plan\n11.reserve transaction\n");
printf("\033[1;32m");
printf("---------\n");
printf("\033[0m");
return;
}
news *new_news(char head_title[],char head_body[],int head_year,int head_month,int head_day)
{
news *outnews =(news *) malloc(sizeof(news));
strcpy(outnews->Title ,head_title);
strcpy(outnews->body ,head_body);
outnews->next = NULL;
outnews->year = head_year;
outnews->month = head_month;
outnews->day = head_day;
return outnews;
}
void addNews(news *head_news, news *new_news) //be akharesh ezafe mishe //struct sakhte shode va head ro migire
{
news *currentnew = head_news;
while (currentnew->next != NULL)
{
currentnew = currentnew->next;
}
currentnew->next = new_news;
}
void makeNews()
{
char head_title[50];
char head_body[300];
int head_year,head_month,head_day;
system("cls");
printf("Enter The News Title :");
fgets (head_title, 50, stdin);
scanf ("%[^\n]%*c", head_title);
printf("Enter The News Text :");
fgets (head_body, 300, stdin);
scanf ("%[^\n]%*c", head_body);
printf("Enter The News End Date (YY/MM/DD):\n");
scanf("%d/%d/%d",&head_year,&head_month,&head_day);
if (newspublished == 0)
{
head_news = new_news(head_title,head_body,head_year,head_month,head_day);
}
else addNews(head_news,new_news(head_title,head_body,head_year,head_month,head_day));
newspublished++;
return;
}
void makeSelf()
{
system("cls");
int Selfid;
char SelfName[30];
char SelfLocation[20];
int SelfCapacity;
char SelfType[10];
char SelfMeals[10];
int lunchHour1,lunchHour2;
int lunchMinute1,lunchMinute2;
int dinnerHour1,dinnerHour2;
int dinnerMinute1,dinnerMinute2;
printf("\nEnter Self's ID:\n");
scanf("%d",&Selfid);
system("cls");
printf("\nEnter Self's Name:");
fgets(SelfName, 30, stdin);
scanf("%[^\n]%*c", SelfName);
system("cls");
printf("\nEnter Self's Location:");
fgets(SelfLocation, 20, stdin);
scanf("%[^\n]%*c", SelfLocation);
system("cls");
printf("Enter Self's Capacity:\n");
scanf("%d",&SelfCapacity);
system("cls");
printf("\nEnter Self's Type (boyish - girlish):\n");
scanf("%s",SelfType);
system("cls");
printf("\nEnter Self's Meal Plan (lunch - dinner - both):\n");
scanf("%s",SelfMeals);
if (strcmp(SelfMeals,"lunch") == 0)
{
printf("\nEnter lunch Limit HH:MM-HH:MM:\n");
scanf("%d:%d-%d:%d",&lunchHour1,&lunchMinute1,&lunchHour2,&lunchMinute2);
}
else if (strcmp(SelfMeals,"dinner") == 0)
{
printf("\nEnter dinner Limit HH:MM-HH:MM:\n");
scanf("%d:%d-%d:%d",&dinnerHour1,&dinnerMinute1,&dinnerHour2,&dinnerMinute2);
}
else if (strcmp(SelfMeals,"both") == 0)
{
printf("\nEnter lunch Limit HH:MM-HH:MM:\n");
scanf("%d:%d-%d:%d",&lunchHour1,&lunchMinute1,&lunchHour2,&lunchMinute2);
printf("\nEnter dinner Limit HH:MM-HH:MM:\n");
scanf("%d:%d-%d:%d",&dinnerHour1,&dinnerMinute1,&dinnerHour2,&dinnerMinute2);
}
system("cls");
printf("Self ID %d Created\n",Selfid);
Sleep(2000);
system("cls");
if (SelfDef == 0)
{
selfhead = newSelf(SelfName,SelfLocation,SelfCapacity,SelfType,SelfMeals,Selfid,
lunchHour1,lunchMinute1,dinnerHour1,dinnerMinute1,
lunchHour2,lunchMinute2,dinnerHour2,dinnerMinute2);
}
else add_Self(selfhead,newSelf(SelfName,SelfLocation,SelfCapacity,SelfType,SelfMeals,Selfid,
lunchHour1,lunchMinute1,dinnerHour1,dinnerMinute1,
lunchHour2,lunchMinute2,dinnerHour2,dinnerMinute2));
SelfDef++;
}
void ChargeByadmin()
{
system("cls");
Node* current = head;
int counter = 1;
while (current != NULL)
{
printf("\033[1;32m");
printf("=== User %d ===",counter);
printf("\033[0m");
printf("\nID: %s\n",current->user_id);
printf("Charge :%lf\n",current->charge);
printf("\033[1;32m");
printf("==============");
printf("\033[0m");
current = current->next;
counter++;
}
char getid[20];
printf("\n\nEnter The User's ID :\n");
scanf("%s",getid);
system("cls");
double chargeamount;
Node* Search = head;
while (Search != NULL)
{
if (stringCmpID(Search,getid))
{
printf("Enter Charge Amount :\n");
scanf("%lf",&chargeamount);
system("cls");
Search->charge += chargeamount;
printf("\033[0;32m");
printf("User");
printf("\033[1;33m");
printf("\" %s \"",Search->user_id);
printf("\033[0;32m");
printf("has been successfully charged ");
printf("\033[1;33m");
printf("%lf",chargeamount);
printf("\033[0;32m");
printf("Amount\n");
printf("\033[0m");
// //test
// printf("\n\n%llu",Search->charge);
// //teste
Sleep(5000);
system("cls");
return;
}
Search= Search->next;
}
printf("User Not Found !\n");
Sleep(2000);
return;
}
void DefineFood()
{
system("cls");
int foodID;
char foodName[20];
int foodtype;
double foodprice;
printf("Enter Food ID :\n");
scanf("%d",&foodID);
printf("Enter Food Name :\n");
scanf("%s",foodName);
printf("\nEnter Food Type ( 1.Food 2.Dessert ) :\n");
scanf("%d",&foodtype);
printf("\nEnter Food Price :\n");
scanf("%lf",&foodprice);
if (fooddef == 0)
{
foodhead = new_food(foodID,foodName,foodtype,foodprice);
}
else add_food(foodhead,new_food(foodID,foodName,foodtype,foodprice));
fooddef++;
system("cls");
printf("Food ID %d Created\n",foodID);
Sleep(2000);
system("cls");
return;
}
void DefineMealPlan()
{
int selfid;
system("cls");
if (selfhead == NULL )
{
printf("No Self Is Defined!\n");
Sleep(2000);
system("cls");
return;
}
int counter = 1;
Self* current = selfhead;
while (current != NULL)
{
printf("\033[1;32m");
printf("======");
printf("\033[0m");
printf("Self %d",counter);
printf("\033[1;32m");
printf("======");
printf("\033[0m");
printf("\nID:%d\n",current->Selfid);
printf("Name :%s\n",current->SelfName);
counter++;
current = current->next;
}
printf("\n\nEnter Self ID :\n");
scanf("%d",&selfid);
system("cls");
Self* current1 = selfhead;
while (current1 != NULL)
{
if (current1->Selfid == selfid)
{
printf("Choose Date YY/MM/DD :\n"); //ye tarikh ke to oon tarikh oon self ke id dadim bayad ghazaye zire ro dashte bashe
scanf("%d/%d/%d",¤t1->selfyear,¤t1->selfmonth,¤t1->selfday);
printf("Choose Meal Type (lunch - dinner - both):\n");
scanf("%s",current1->SelfMeals);
int cnt = 1;
food* c2 = foodhead;
system("cls");
while (c2 != NULL)
{
printf("=== Food %d =====\n",cnt);
printf("ID:%d\n",c2->foodID);
printf("Name :%s\n",c2->nameFood);
c2 = c2->next;
cnt++;
}
int getfood;
int i = 0;
int option;
while (option != 2)
{
printf("\nChoose a Food ID:\n");
scanf("%d",&getfood);
food* c3 = foodhead;
while (c3 != NULL)
{
if (c3->foodID == getfood)
{
printf("Enter %s Count :\n",c3->nameFood);
strcpy(current1->foods[i],c3->nameFood);
// scanf("%d",&c3->foodCount);
scanf("%d",¤t1->foodCount[i]);
FoodsForSelf++;
printf("Do You want to add more food? \n1.Yes\n2.No?\n");
scanf("%d",&option);
}
c3 = c3->next;
}
i++;
}
system("cls");
printf("Meal Plan For Self %d Created For %d/%d/%d",selfid,current1->selfyear,current1->selfmonth,current1->selfday);
current1->mealplandefined = 1;
Sleep(7000);
system("cls");
return;
}
current1 = current1->next;
}
system("cls");
}
void reservetransaction()
{
system("cls");
Self* current = selfhead;
int cnt = 1;
while (current != NULL)
{
if (current->mealplandefined == 0)
{
current = current->next;
}
printf("\n==== Self %d ====\n",cnt);
printf("Name : %s\n",current->SelfName);
printf("ID : %d\n",current->Selfid);
printf("Meal Type : %s\n",current->SelfMeals);
printf("Capacity :%d\n",current->SelfCapacity);
for (int i = 0; i < FoodsForSelf; i++)
{
printf("Food %s Left:%d\n",current->foods[i],current->foodCount[i]);
}
current = current->next;
cnt++;
}
if (current == NULL)
{
system("cls");
printf("No Data Stored");
Sleep(2000);
system("cls");
return;
}
Sleep(10000);
system("cls");
return;
}
void menu2()
{
int menu2;
system("cls");
while (1)
{
system("cls");
showAdminMenu();
scanf("%d",&menu2);
if (menu2 == 1)
{
if (head == NULL)
{
system("cls");
printf("No Data is Stored.\n");
Sleep(3500);
system("cls");
continue;
}
print_list(head);
//approve statue
print_listMenu();
}
else if (menu2 == 2)
{
makeNews();
}
else if (menu2 == 3)
{
transmit();
}
else if (menu2 == 4)
{
system("cls");
printf("Logout Succesfull\n");
adminStatus = 0;
admin2Status = 0;
Sleep(2000);
system("cls");
main();
}
else if (menu2 == 5)
{
ChangePassAdmin();
}
else if (menu2 == 6)
{
ChangeTime();
}
else if (menu2 == 7)
{
ChargeByadmin();
}
else if (menu2 == 8)
{
makeSelf();
}
else if (menu2 == 9)
{
DefineFood();
}
else if (menu2 == 10)
{
DefineMealPlan();
}
else if (menu2 == 11)
{
reservetransaction();
}
}
}
int checkReserveGender(char genderUser[],char genderSelf[])
{
if (strcmp(genderSelf,"boyish")== 0 && strcmp(genderUser,"male") == 0)
{
return 1;
}
else if(strcmp(genderSelf,"girlish")== 0 && strcmp(genderUser,"female") == 0)
{
return 1;
}
else return 0;
}
int checkreservetime(Self* now)
{
if (godtime == 1)
{
if ( ( (changeDay + 2 <= now->selfday) && (changeMonth <= now->selfmonth) && (changeYear == now->selfyear ) && (now->selfday - changeDay <= 14) ) )
{
return 1;
}
else return 0;
}
else if (godtime == 0)
{
if ( ( (headtime->tm_mday + 2 <= now->selfday) && (headtime->tm_mon + 1 <= now->selfmonth) && (headtime->tm_year +1900 == now->selfyear ) && (now->selfday - headtime->tm_mday <= 14) ) )
{
return 1;
}
else return 0;
}
else return 0;
}
void checkIfreserve(Node* current,Self* now,food* alan)
{
if ((current->charge >= alan->foodPrice ))
{
if ((checkReserveGender(current->gender,now->SelfType) == 1 ))
{
if ((checkreservetime(now) == 1))
{
if (latereserve == 1)
{
if (godtime == 0 &&( now->dinnerMinute1 - 30 >= headtime->tm_min || now->lunchMinute1 -30 >= headtime->tm_min)
||(godtime == 1 &&( now->dinnerMinute1 - 30 >= changeMinute || now->lunchMinute1 -30 >= changeMinute ) ))
{
current->charge -= 2 * alan->foodPrice;
}
}
else current->charge -= alan->foodPrice;
current->self_reserveId = now->Selfid;
current->foodoption = alan->foodID;
now->SelfCapacity -= 1;
int i = 0;
while (strcmp(now->foods[i],alan->nameFood) != 0)
{
i++;
}
now->foodCount[i] -= 1;
// //
// printf("Count %s:%d\n",now->foods[i],now->foodCount[i]);
// Sleep(5000);
// //
latereserve = 0;
system("cls");
printf("Reserve Successful\n");
Sleep(5000);
return ;
}
else
{
latereserve = 0;
printf("Can't Reserve at this time\n");
Sleep(3000);
return;
}
}
else
{
printf("This Self Doesn't Match Your Gender\n");
Sleep(3000);
return;
}
}
else {
printf("You Don't Have Enough Credit\n");
Sleep(3000);
comefromreserve = 1;
ChargeMenu(current->user_id);
}
}
void reserveFood(char loginuserid[])
{
system("cls");
int cnt = 1;
char chooseFoodOption[20];
int chooseSelfID;
Self* current = selfhead;
system("cls");
while (current != NULL)
{
if (current->mealplandefined == 0)
{
current = current->next;
}
printf("\n==== Self %d ====\n",cnt);
printf("Name : %s\n",current->SelfName);
printf("ID : %d\n",current->Selfid);
printf("Meal Type : %s\n",current->SelfMeals);
printf("Food Options :\n");
for (int i = 0; i < FoodsForSelf; i++)
{
if (current->foods[i] == NULL)
{
break;
}