From 4ebc697053bfe30ae043e499d99d1007cf932bd7 Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Sun, 22 Jan 2023 09:29:21 +0100 Subject: [PATCH] Implementation of function menu(). --- src/CustomerMenu.c | 30 +++++++++++++++++++++--------- src/CustomerMenu.h | 3 +++ src/CustomerProperties.h | 5 +++-- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/CustomerMenu.c b/src/CustomerMenu.c index 78a067a..a7a1c0d 100644 --- a/src/CustomerMenu.c +++ b/src/CustomerMenu.c @@ -4,19 +4,19 @@ void customerChoiceForMenuItem(int numberOfMenuItem) { switch(numberOfMenuItem){ case 1: - printf("You have choosen to send money.\n"); + printf("You have chosen to send money.\n"); //call sendMoney(); break; case 2: - printf("You have choosen to withdraw money.\n"); + printf("You have chosen to withdraw money.\n"); //call withDrawMoney(); break; case 3: - printf("You have choosen to deposit money.\n"); + printf("You have chosen to deposit money.\n"); //call depositMoney(); break; case 4: - printf("You have choosen to request a loan.\n"); + printf("You have chosen to request a loan.\n"); //call requestLoan(); break; default: @@ -29,26 +29,38 @@ void showAllMenuEntries() int userDecision = 0; - puts("\n\n\n"); + puts("\n\n"); puts("CUSTOMER MENU"); puts("\n"); printf("Select between (1-4):"); puts("\n\n\n"); - printf(">->->1. send money<-<-<"); + printf("->->->1. send money<-<-<-"); puts("\n\n\n"); - printf(">->->2. withdraw money<-<-<"); + printf("->->->2. withdraw money<-<-<-"); puts("\n\n\n"); - printf(">->->3. deposit money<-<-<"); + printf("->->->3. deposit money<-<-<-"); puts("\n\n\n"); - printf(">->->4. request loan<-<-<"); + printf("->->->4. request loan<-<-<-"); puts("\n\n\n"); puts("Your decision: "); scanf("%d",&userDecision); customerChoiceForMenuItem(userDecision); } + +void menu(customer_t *c) +{ + if(c==NULL){ + puts("Invalid pointer. Aborting.\n"); + exit(-1); + }else{ + printf("Welcome %s %s!\n",c->forename, c->surname); + printf("Balance: %.4f€\n",c->balance); + showAllMenuEntries(); + } +} diff --git a/src/CustomerMenu.h b/src/CustomerMenu.h index 5839a26..bba3414 100644 --- a/src/CustomerMenu.h +++ b/src/CustomerMenu.h @@ -1,3 +1,6 @@ #include +#include +#include "CustomerProperties.h" void customerChoiceForMenuItem(int); void showAllMenuEntries(); +void menu(customer_t *); diff --git a/src/CustomerProperties.h b/src/CustomerProperties.h index 2bbab62..8e3a27e 100644 --- a/src/CustomerProperties.h +++ b/src/CustomerProperties.h @@ -1,4 +1,5 @@ -typedef struct Customer{ - char *ID, *forename, *surname, *password; +typedef struct Customer +{ + char *ID,*forename, *surname,*password; float balance; }customer_t;