Browse Source

Integrated the customer menu in our programm. The user gains access to the customer menu if the login was successful. From there the user can choose between different menu entries. In the build-script, the file customerMenu.c is added to the files which get compiled.

remotes/origin/development
fdai7057 2 years ago
parent
commit
f55f596853
  1. 2
      build-script.sh
  2. 5
      src/customerMenu.c
  3. 5
      src/loginCustomer.c
  4. 1
      src/loginCustomer.h
  5. 1
      test/test_LoginCustomer.c

2
build-script.sh

@ -2,7 +2,7 @@ clear
ceedling test:all
rm -r build
cd src/
gcc helperFunctions.c error.c loginCustomer.c createCustomer.c mainMenu.c program.c -lm -o program.out
gcc helperFunctions.c error.c loginCustomer.c customerMenu.c createCustomer.c mainMenu.c program.c -lm -o program.out
./program.out
rm program.out
cd ..

5
src/customerMenu.c

@ -56,11 +56,10 @@ void showAllMenuEntries()
void menu(customer_t *c)
{
if(c==NULL){
puts("Invalid pointer. Aborting.\n");
puts("Invalid pointer. Aborting!");
exit(-1);
}else{
printf("Welcome %s %s!\n",c->forename, c->surname);
printf("Balance: %.4f€\n",c->balance);
puts("Welcome!");
showAllMenuEntries();
}
}

5
src/loginCustomer.c

@ -44,8 +44,9 @@ void collectCustomerDataForLogin(int attempts)
bool loginSuccessful = loginCustomer(&c);
free(c.IDAsString);
free(c.password);
if(loginSuccessful ) {
printf("Welcome!\n");
if(loginSuccessful) {
//call menu();
menu(&c);
}else if(!loginSuccessful && attempts < MAX_LOGIN_ATTEMPTS){
printf("You have %d attempts left.\n", MAX_LOGIN_ATTEMPTS - attempts);
collectCustomerDataForLogin(++attempts);

1
src/loginCustomer.h

@ -5,6 +5,7 @@
#include <stdbool.h>
#include <string.h>
#include "createCustomer.h"
#include "customerMenu.h"
#include "error.h"
#define MAX_LOGIN_ATTEMPTS 3
bool checkLogin(bool);

1
test/test_LoginCustomer.c

@ -1,5 +1,6 @@
#include <unity.h>
#include "../src/loginCustomer.c"
#include "../src/customerMenu.c"
#include "../src/helperFunctions.c"
#include "../src/error.c"
void setUp(){};

Loading…
Cancel
Save