diff --git a/src/CustomerData.txt b/src/CustomerData.txt index f847b08..51ffa90 100644 --- a/src/CustomerData.txt +++ b/src/CustomerData.txt @@ -3,7 +3,7 @@ ID=1234 forename=Max Surname=Mustermann password=example -balance=2000 +balance=4999 1327=example ID=1327 diff --git a/src/a.exe b/src/a.exe index cdc9794..bbfdb5f 100644 Binary files a/src/a.exe and b/src/a.exe differ diff --git a/src/depositMoney.c b/src/depositMoney.c index 67c9012..50f5b3e 100644 --- a/src/depositMoney.c +++ b/src/depositMoney.c @@ -1,4 +1,5 @@ -#include "DepositMoney.h" +#include "depositMoney.h" +#include "updateCustomerAccountBalance.c" void AskToTryAgain(bool afterError){ char choice; @@ -11,32 +12,27 @@ void AskToTryAgain(bool afterError){ scanf(" %c", &choice); switch(choice){ case 'y': - DepositMoney(); + DepositMoney(1234,500); break; case 'n': break; } } -int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance){ //type of int to returnpossible end cases. - - - return 1; -} -int DepositMoney(){ - //TODO: Set a minimum deposit amount. - float amountToDeposit; - float availableAccountBalance = 10000; //for testing purposes. will be replaced with an actual function to retrieve this data. - - printf("\nPlease enter the amount to deposit: "); - scanf("%f", &amountToDeposit); +int DepositMoney(int customerID, float amountToDeposit){ + float availableAccountBalance=getAvailableAccountBalance(customerID); if(amountToDeposit>0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){ //InitiateDepositMoney(amountToDeposit,availableAccountBalance); - printf("You have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); - AskToTryAgain(false); - return 0; + if(updateAvailableAccountBalance(customerID, amountToDeposit, true)==0){ + printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit); + AskToTryAgain(false); + return 0; + }else{ + printf("Something went wrong. Please contact staff."); + return 3; + } }else if(amountToDeposit>0){ printf("The amount you entered is lower than the minimum amount."); AskToTryAgain(true); @@ -50,7 +46,5 @@ int DepositMoney(){ int main() { - char any; - DepositMoney(); - scanf("%c", &any); + DepositMoney(1234,500); } diff --git a/src/depositMoney.h b/src/depositMoney.h index b6a09ec..306aaab 100644 --- a/src/depositMoney.h +++ b/src/depositMoney.h @@ -5,5 +5,5 @@ int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance); -int DepositMoney(); +int DepositMoney(int customerID, float amountToDeposit); void AskToTryAgain(bool afterError);