|
@ -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; |