-
Notifications
You must be signed in to change notification settings - Fork 0
/
gjc.c
executable file
·82 lines (69 loc) · 2.34 KB
/
gjc.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
/****************************************************************************
* COSC2541 - Programming Techniques
* Semester 2 2011 Assignment #2
* Full Name : Dang Nguyen Hoang Gia
* Student Number : s3269900
* Start up code provided by Christopher Hoobin, Xiaodong Li and Quang Tran
****************************************************************************/
#include "gjc.h"
#include "gjc_options.h"
#include "gjc_utility.h"
#include "string.h"
int main(int argc, char* argv[])
{
GJCType gjc;
int initFlag, dataFlag, exitFlag=FALSE;
char c[MAX_OPTION_INPUT+EXTRA_SPACES];
/* Initialise the Gloria Jean's Coffee system to a safe empty state. */
initFlag = systemInit(&gjc);
/* Populate the Gloria Jean's Coffee system with data from the data files. */
/* Uncomment this line when you are ready to use command line arguments:*/
if(argv[1]==NULL||argv[2]==NULL){
printf("No argument found\n");
exit(EXIT_SUCCESS);
}
dataFlag = loadData(&gjc, argv[1], argv[2]);
/* Testing to see if both systemInit(.) and loadData(.) are ok */
if (initFlag == FAILURE || dataFlag == FAILURE){
exit(EXIT_FAILURE);
}
/* Interactive menu providing user with access to the 9 menu options */
while(exitFlag==FALSE){
printf("Main Menu:\n");
printf("(1) Hot Drinks Summary\n");
printf("(2) Cold Drinks Summary\n");
printf("(3) Detailed Menu Report\n");
printf("(4) Add Menu Category\n");
printf("(5) Delete Menu Category\n");
printf("(6) Add Menu Item\n");
printf("(7) Delete Menu Item\n");
printf("(8) Save & Exit\n");
printf("(9) Abort\n");
printf("Select your option (1-9):");
fgets(c,MAX_OPTION_INPUT+EXTRA_SPACES,stdin);
if(c[0]=='\n'){
printf("Invalid input\n");
}else if(stringIsInRange(c,MAX_OPTION_INPUT)==FALSE){
readRestOfLine();
printf("Invalid input\n");
}else{
stripNewLine(c);
if(strcmp(c,"1")==0){
displaySummary(&gjc,HOT);
}else if(strcmp(c,"2")==0){
displaySummary(&gjc,COLD);
}else if(strcmp(c,"3")==0){
}else if(strcmp(c,"4")==0){
}else if(strcmp(c,"5")==0){
}else if(strcmp(c,"6")==0){
}else if(strcmp(c,"7")==0){
}else if(strcmp(c,"8")==0){
}else if(strcmp(c,"9")==0){
exitFlag=TRUE;
}
}
}
/* Deallocate all dynamically allocated memory. */
systemFree(&gjc);
exit(EXIT_SUCCESS);
}