Browse Source

Fix an error of deposit function

remotes/origin/feature/transfer-money
fdlt3817 2 years ago
parent
commit
f5d1684e33
  1. 11
      src/depositMoney.c

11
src/depositMoney.c

@ -1,8 +1,9 @@
#include "depositMoney.h" #include "depositMoney.h"
#include "updateCustomerAccountBalance.c" #include "updateCustomerAccountBalance.c"
void askToTryAgain(bool afterError){
void askToTryAgain(bool afterError, int customerID){
char choice; char choice;
printf("\n"); printf("\n");
if(afterError){ if(afterError){
printf("Would you like to try again? [y] yes [n] no: "); printf("Would you like to try again? [y] yes [n] no: ");
@ -12,7 +13,7 @@ void askToTryAgain(bool afterError){
scanf(" %c", &choice); scanf(" %c", &choice);
switch(choice){ switch(choice){
case 'y': case 'y':
depositMoney(1234,500);
depositMoney(customerID);
break; break;
case 'n': case 'n':
break; break;
@ -33,7 +34,7 @@ bool depositMoney(int customerID){
//InitiateDepositMoney(amountToDeposit,availableAccountBalance); //InitiateDepositMoney(amountToDeposit,availableAccountBalance);
if(updateAvailableAccountBalance(customerID, availableAccountBalance+amountToDeposit)==0){ if(updateAvailableAccountBalance(customerID, availableAccountBalance+amountToDeposit)==0){
printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit);
askToTryAgain(false);
askToTryAgain(false,customerID);
return true; return true;
}else{ }else{
printf("Something went wrong. Please contact staff."); printf("Something went wrong. Please contact staff.");
@ -41,11 +42,11 @@ bool depositMoney(int customerID){
} }
}else if(amountToDeposit>0){ }else if(amountToDeposit>0){
printf("The amount you entered is lower than the minimum amount."); printf("The amount you entered is lower than the minimum amount.");
askToTryAgain(true);
askToTryAgain(true,customerID);
return false; //amount lower than minimum deposit amount return false; //amount lower than minimum deposit amount
}else{ }else{
printf("Invalid input."); printf("Invalid input.");
askToTryAgain(true);
askToTryAgain(true,customerID);
return false; //invalid input return false; //invalid input
} }
return false; return false;
Loading…
Cancel
Save