From 506838714140d5ed54d3693fe25d9527606548b9 Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Mon, 6 Feb 2023 15:29:36 +0100 Subject: [PATCH] Modification of the function customerChoiceForMenuItem(). Change void to int. This function now has a return value. Each return value has a meaning. The meaning of the return value lies in the user's choice for a menu item. --- src/customerMenu.c | 11 +++++++++-- src/customerMenu.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/customerMenu.c b/src/customerMenu.c index 436a4c3..b3bb522 100644 --- a/src/customerMenu.c +++ b/src/customerMenu.c @@ -1,27 +1,34 @@ #include "customerMenu.h" -void customerChoiceForMenuItem(int numberOfMenuItem) +int customerChoiceForMenuItem(int numberOfMenuItem) { + int returnStatus = 0; switch(numberOfMenuItem){ case 1: puts("You have chosen to send money.\n"); + returnStatus = 1; //call sendMoney(); break; case 2: puts("You have chosen to withdraw money.\n"); + returnStatus = 2; //call withDrawMoney(); break; case 3: puts("You have chosen to deposit money.\n"); + returnStatus = 3; //call depositMoney(); break; case 4: puts("You have chosen to request a loan.\n"); + returnStatus = 4; //call requestLoan(); break; default: - puts("Invalid input.\n"); + puts("Invalid input."); + returnStatus = -1; } + return returnStatus; } void showAllMenuEntries() diff --git a/src/customerMenu.h b/src/customerMenu.h index dd05fd0..4b51d22 100644 --- a/src/customerMenu.h +++ b/src/customerMenu.h @@ -1,6 +1,6 @@ #include #include #include "customerProperties.h" -void customerChoiceForMenuItem(int); +int customerChoiceForMenuItem(int); void showAllMenuEntries(); void menu(customer_t *);