Browse Source

implement the function menuInput(), in order for the user to choose a menu option.

remotes/origin/feature/customer-creation
fdai7207 2 years ago
parent
commit
26ea996b0b
  1. 56
      src/mainMenu.c
  2. 1
      src/mainMenu.h

56
src/mainMenu.c

@ -31,6 +31,7 @@ bool chooseOption(int choiceInput)
else else
{ {
return true; return true;
} }
@ -54,12 +55,13 @@ void ageInput()
if((checkIfInteger(userInput))&& (agePermission(age))) if((checkIfInteger(userInput))&& (agePermission(age)))
{ {
//age = strtol(userInput,&userInputPointer,10);
printf("Access granted!\n\n\n\n"); printf("Access granted!\n\n\n\n");
showMenu(); showMenu();
menuInput();
break; break;
} }
@ -85,6 +87,57 @@ void ageInput()
} }
void menuInput()
{
char choiceInput[20];
char* choiceInputPointer;
int selection;
scanf("%s",choiceInput);
while(true)
{
selection = strtol(choiceInput,&choiceInputPointer,10);
if(chooseOption(selection) == true && checkIfInteger(choiceInput) == true)
{
switch(selection)
{
case 1 : printf("\nLoginAsCostumer() function will be implemented here soon\n\n");
break;
case 2 : printf("\ncreateCostumerAccount() function will be implemented here soon\n\n");
break;
case 3 : printf("\nLoginAsEmployee() function will be implemented here soon\n\n");
break;
case 4 : printf("\e[1;1H\e[2J");
printf("\nsee you next time !\n\n");
break;
}
break;
}
else
{
printf("Input invalid! try again!\n");
scanf("%s",choiceInput);
}
}
}
void showMenu() void showMenu()
{ {
@ -99,4 +152,3 @@ void showMenu()
} }

1
src/mainMenu.h

@ -11,6 +11,7 @@ bool checkIfInteger(char* userInput);
bool chooseOption(int choiceInput); bool chooseOption(int choiceInput);
void ageInput(); void ageInput();
void menuInput();
void showMenu(); void showMenu();
#endif #endif

Loading…
Cancel
Save