From 19a21ef71ca65c98234780ff5c0c5b898411bd85 Mon Sep 17 00:00:00 2001 From: fdlt3817 Date: Fri, 10 Feb 2023 11:40:30 +0100 Subject: [PATCH] Create withdrawal loop, edit customer data for testing --- src/CustomerData.txt | 40 +++++++++++++++++++++++++++------------- src/withdrawMoney.c | 24 +++++++++++++++--------- src/withdrawMoney.h | 2 +- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/CustomerData.txt b/src/CustomerData.txt index 106adfc..9d1f9d5 100644 --- a/src/CustomerData.txt +++ b/src/CustomerData.txt @@ -1,20 +1,34 @@ 1234=example ID=1234 -forename=Max -Surname=Mustermann +forename=Test +Surname=Testermann password=example -balance=2300 +balance=120.5 -1327=example -ID=1327 -forename=Max -Surname=Mustermann +1235=example +ID=1235 +forename=Test +Surname=Testermann password=example -balance=160 +balance=340 -1666=example -ID=1666 -forename=Max -Surname=Mustermann +1236=example +ID=1236 +forename=Test +Surname=Testermann password=example -balance=190 +balance=244.5 + +1237=example +ID=1237 +forename=Test +Surname=Testermann +password=example +balance=340 + +1238=example +ID=1238 +forename=Test +Surname=Testermann +password=example +balance=1200 diff --git a/src/withdrawMoney.c b/src/withdrawMoney.c index fd955c9..1f42417 100644 --- a/src/withdrawMoney.c +++ b/src/withdrawMoney.c @@ -2,16 +2,18 @@ #include "updateCustomerAccountBalance.c" #include "currentCustomerAccountBalance.c" -void notifyCustomer(float amountToWithdraw, float remainingAccountBalance) { - char returnToHomeInput; +void notifyCustomer(float amountToWithdraw, float remainingAccountBalance, int user_id) { + char c; - printf("You have successfully withdrawn %f €.\n", amountToWithdraw); - printf("Remaining account balance: %f €\n\n", remainingAccountBalance); - printf("Press any key to return to home page: "); - scanf("%c", &returnToHomeInput); + printf("You have successfully withdrawn %.2f €.\n", amountToWithdraw); + printf("Remaining account balance: %.2f €\n\n", remainingAccountBalance); + printf("Would you like to do another withdrawal? [y] yes [any] no\n"); + scanf(" %c", &c); - if (returnToHomeInput) { - //showAllMenuEntries(); + if (c=='y'||c=='Y') { + withdraw(user_id); + }else{ + return; } } @@ -36,7 +38,7 @@ bool withdraw(int user_id) { remainingAccountBalance = initiateWithdraw(amountToWithdraw, availableAccountBalance); updateSuccess = updateAvailableAccountBalance(user_id, remainingAccountBalance); if( updateSuccess ) { - notifyCustomer(amountToWithdraw, remainingAccountBalance); + notifyCustomer(amountToWithdraw, remainingAccountBalance, user_id); return true; } else { @@ -83,3 +85,7 @@ bool withdrawSpecificAmount(int user_id, float amountToWithdraw) { return false; } +int main(){ + withdraw(1234); + return 1; +} \ No newline at end of file diff --git a/src/withdrawMoney.h b/src/withdrawMoney.h index 972bf74..752c154 100644 --- a/src/withdrawMoney.h +++ b/src/withdrawMoney.h @@ -6,7 +6,7 @@ bool withdraw(int user_id); float initiateWithdraw(float amountToWithdraw, float availableAccountBalance); -void notifyCustomer(float amountToWithdraw, float remainingAccountBalance); +void notifyCustomer(float amountToWithdraw, float remainingAccountBalance, int user_id); bool withdrawSpecificAmount(int user_id, float amountToWithdraw); #endif \ No newline at end of file