Browse Source

Integrated updateAccountBalance and getAccountBalance into the deposit function

remotes/origin/feature/deposit-system
fdlt3817 2 years ago
parent
commit
f5015a6b13
  1. 2
      src/CustomerData.txt
  2. BIN
      src/a.exe
  3. 30
      src/depositMoney.c
  4. 2
      src/depositMoney.h

2
src/CustomerData.txt

@ -3,7 +3,7 @@ ID=1234
forename=Max forename=Max
Surname=Mustermann Surname=Mustermann
password=example password=example
balance=2000
balance=4999
1327=example 1327=example
ID=1327 ID=1327

BIN
src/a.exe

30
src/depositMoney.c

@ -1,4 +1,5 @@
#include "DepositMoney.h"
#include "depositMoney.h"
#include "updateCustomerAccountBalance.c"
void AskToTryAgain(bool afterError){ void AskToTryAgain(bool afterError){
char choice; char choice;
@ -11,32 +12,27 @@ void AskToTryAgain(bool afterError){
scanf(" %c", &choice); scanf(" %c", &choice);
switch(choice){ switch(choice){
case 'y': case 'y':
DepositMoney();
DepositMoney(1234,500);
break; break;
case 'n': case 'n':
break; 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){ if(amountToDeposit>0 && amountToDeposit>MINIMUM_DEPOSIT_AMOUNT){
//InitiateDepositMoney(amountToDeposit,availableAccountBalance); //InitiateDepositMoney(amountToDeposit,availableAccountBalance);
printf("You have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit);
if(updateAvailableAccountBalance(customerID, amountToDeposit, true)==0){
printf("\nYou have successfully deposited %.2f. New account balance is %.2f", amountToDeposit, availableAccountBalance+amountToDeposit);
AskToTryAgain(false); AskToTryAgain(false);
return 0; return 0;
}else{
printf("Something went wrong. Please contact staff.");
return 3;
}
}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);
@ -50,7 +46,5 @@ int DepositMoney(){
int main() int main()
{ {
char any;
DepositMoney();
scanf("%c", &any);
DepositMoney(1234,500);
} }

2
src/depositMoney.h

@ -5,5 +5,5 @@
int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance); int InitiateDepositMoney(float amountToDeposit, float availableAccountBalance);
int DepositMoney();
int DepositMoney(int customerID, float amountToDeposit);
void AskToTryAgain(bool afterError); void AskToTryAgain(bool afterError);
Loading…
Cancel
Save