From 635efaadf29c1a8128729cd47c4d97a757943aaf Mon Sep 17 00:00:00 2001 From: fdlt3817 Date: Fri, 10 Feb 2023 21:50:28 +0100 Subject: [PATCH] Refactor withdrawMoney --- src/withdrawMoney.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/withdrawMoney.c b/src/withdrawMoney.c index 65e23b2..cfea08b 100644 --- a/src/withdrawMoney.c +++ b/src/withdrawMoney.c @@ -81,23 +81,22 @@ bool withdraw(int user_id) { bool withdrawSpecificAmount(int user_id, float amountToWithdraw) { float remainingAccountBalance; - float availableAccountBalance = getAvailableAccountBalance(user_id); - if (amountToWithdraw > 0) { + if (amountToWithdraw > 0) { if (amountToWithdraw <= availableAccountBalance) { - remainingAccountBalance = initiateWithdraw(amountToWithdraw, availableAccountBalance); - if(updateAvailableAccountBalance(user_id, remainingAccountBalance)){ + if (updateAvailableAccountBalance(user_id, remainingAccountBalance)) { return true; } - - } } + } + return false; } + // int main(){ // withdraw(1234); // return 1; -// } \ No newline at end of file +// }