From 26ea996b0b78ca83e38dcce7bb8bc3bab6898544 Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Mon, 30 Jan 2023 16:26:43 +0100 Subject: [PATCH] implement the function menuInput(), in order for the user to choose a menu option. --- src/mainMenu.c | 64 +++++++++++++++++++++++++++++++++++++++++++++----- src/mainMenu.h | 1 + 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/mainMenu.c b/src/mainMenu.c index eca4c34..bed41d9 100644 --- a/src/mainMenu.c +++ b/src/mainMenu.c @@ -1,4 +1,4 @@ -#include "mainMenu.h" +#include"mainMenu.h" bool agePermission(int age) @@ -24,14 +24,15 @@ bool checkIfInteger(char* userInput) bool chooseOption(int choiceInput) { - if(choiceInput < 1 || choiceInput > 4) + if(choiceInput<1 || choiceInput>4) { - return false; + return false; } else { - return true; + + return true; } } @@ -54,11 +55,12 @@ void ageInput() if((checkIfInteger(userInput))&& (agePermission(age))) { - //age = strtol(userInput,&userInputPointer,10); printf("Access granted!\n\n\n\n"); showMenu(); + + menuInput(); 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() { @@ -99,4 +152,3 @@ void showMenu() } - diff --git a/src/mainMenu.h b/src/mainMenu.h index 6974d21..1be573f 100644 --- a/src/mainMenu.h +++ b/src/mainMenu.h @@ -11,6 +11,7 @@ bool checkIfInteger(char* userInput); bool chooseOption(int choiceInput); void ageInput(); +void menuInput(); void showMenu(); #endif