diff --git a/src/updateCustomerAccountBalance.c b/src/updateCustomerAccountBalance.c index 566f2fd..2040a6d 100644 --- a/src/updateCustomerAccountBalance.c +++ b/src/updateCustomerAccountBalance.c @@ -44,10 +44,9 @@ void replaceBalanceInString(float replacementBalance, int currentLine) { replaceLineInFile("CustomerData.txt",currentLine,newBalanceLine); } -bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool positive){ +bool updateAvailableAccountBalance(int user_id, float newBalance){ bool keep_reading = true; - float availableBalance = 0; char buffer[MAX_LENGTH]; char stringID[MAX_LENGTH] = "ID="; @@ -73,18 +72,10 @@ bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool posi fgets(buffer, MAX_LENGTH, file); strcpy(balance_String, buffer); currentLine+=4; - availableBalance = fetchBalanceFromBalanceString(balance_String); keep_reading = false; } } - fclose(file); - float newBalance = (positive) ? availableBalance+changeInBalance : availableBalance-changeInBalance; + fclose(file);; replaceBalanceInString(newBalance,currentLine); } -int main(){ - - updateAvailableAccountBalance(1234,500,true); - - return 0; -} \ No newline at end of file diff --git a/src/updateCustomerAccountBalance.h b/src/updateCustomerAccountBalance.h index 4af3f89..29f5b75 100644 --- a/src/updateCustomerAccountBalance.h +++ b/src/updateCustomerAccountBalance.h @@ -6,6 +6,6 @@ #define MAX_LENGTH 100 -bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool positive); +bool updateAvailableAccountBalance(int user_id, float newBalance); -void replaceBalanceInString(float replacementBalance, int currentLine); \ No newline at end of file +void replaceBalanceInString(float replacementBalance, int currentLine);