Browse Source

Create withdrawal loop, edit customer data for testing

remotes/origin/feature/balance-operations
fdlt3817 2 years ago
parent
commit
19a21ef71c
  1. 40
      src/CustomerData.txt
  2. 24
      src/withdrawMoney.c
  3. 2
      src/withdrawMoney.h

40
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

24
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;
}

2
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
Loading…
Cancel
Save