From d9925a3a948531bddc70e48efd8451fda91b4f8d Mon Sep 17 00:00:00 2001 From: fdlt3817 Date: Sat, 28 Jan 2023 16:28:55 +0100 Subject: [PATCH] Expanded the function to work with negative balance changes. --- src/CustomerData.txt | 2 +- src/a.exe | Bin 269211 -> 269210 bytes src/lineReplacer.h | 6 ++++++ src/updateCustomerAccountBalance.c | 15 ++++++++------- src/updateCustomerAccountBalance.h | 6 ++++-- 5 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 src/lineReplacer.h diff --git a/src/CustomerData.txt b/src/CustomerData.txt index 05ec80e..d5c417b 100644 --- a/src/CustomerData.txt +++ b/src/CustomerData.txt @@ -3,4 +3,4 @@ ID=1234 forename=Max Surname=Mustermann password=example -balance=1000 \ No newline at end of file +balance=2000 \ No newline at end of file diff --git a/src/a.exe b/src/a.exe index 4083994a33269e5e2e3ac93d883afcbc797f6ad3..f28e6b38fe554253bb67e09ed3c5a78bb7a8dba4 100644 GIT binary patch delta 19365 zcmb_@d016d_y1Y@a0!s%qB4VA8Jray%Nd-yDjLp1Dj0$j!(~!5_2PhuNP@@O<`ia@ z_L`w+S5td2?M=%J&B`(p&9^YEu+hxo_u2QH%e|-X^ZVobJm2%U?^^q_hQ0RM!`bH? z+-5UwwHYhc$$^7EsVp1As_QGic$1FSRMJhicC+&(so`*@B$>+svbIQ4S<6zRqdw44 zFHl}^k6>-`m80%v%2eo)Y?`E49=S#vm9ZXCA?Fvu$6{aM!;tVCNU5RpLqKPgQjcvk zPl@$x+wR$1;N=!Fm)>jW2YzH}qq)@W`pB}0*PwsOy!tdXbjnpSJ;NwnS?3u`K}hba?~`AN;qRs<1X;LQwBs`iq~V;>%d4wLnb0vD`#`zq8Ke|@1^CPbaJ%@g zrl!(U4cnBLye6=q9OZYfOe$68w0MH`4N;D?7(&C9`z?A#pUM{T4sX0O*jzRoA)RXY zF-ww4Y72rK_0N>C-fgH@$@2aqbTVY-a>M3z!ss1v8|>VvhHFZ(Pe?laMoQVt?Z=rugILa{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C%A{2q334hS~!; zr$KrHSyk_1VtP(?Jj@vDCp9*9esV0Ju0ZYGk3lOv5c~Br&L0bNZM`ALq%0@}YdTv7 zWQGPQ0fN5Nv?E&W1Y!iWkL)0j%Nom{0okFkbH!h3Dw*oN7KUy^sSFf)>O}v=yZnuL z^2UqZ%KAA-oR^uDjddKYX&eNd=b9c`0;$!^Q&%9>s&U~h{(Aus@v$$K#Q%ZJ%LSCD zF|-m$t!8O&17dp_Yc;(Gh*)*j{46>-1w_n&9r+%JL9+sW1rn^;`_BR}PY3Fw8Jm`B zc^s&!kB2brgBR5HOP%$30k9@Q&7o5TP`GDxF$Rd>?4zFrM11T>ULa18j+(%}0j2Nk z4&fOoH4Q&d)jNcHL6R_1TaSp^cC^aY*xAdY>To=)*LZmxYL%K`e+eXA6YSrBIB84~ zUcPtL1kw+PJtD$^Za@~*w~Eb4wLH09ouTn^Ae729-H!z#<`E!*H8(LmGbuGY@ld_f x;ytJ^-?bhQwHatt0&1P>oP*7s-gokxk&v8_oe-0hnlLCcEyetulhbkE{|6_rasB`R diff --git a/src/lineReplacer.h b/src/lineReplacer.h new file mode 100644 index 0000000..999855c --- /dev/null +++ b/src/lineReplacer.h @@ -0,0 +1,6 @@ +#include +#include +#include +#include + +void replaceLineInFile(const char* file_name, int line, const char* new_line); //replaces the line at "line" on the file "file_name", with the new line "new_line". \ No newline at end of file diff --git a/src/updateCustomerAccountBalance.c b/src/updateCustomerAccountBalance.c index 6ee64e9..764c317 100644 --- a/src/updateCustomerAccountBalance.c +++ b/src/updateCustomerAccountBalance.c @@ -1,7 +1,8 @@ #include "updateCustomerAccountBalance.h" #include "currentCustomerAccountBalance.c" +#include "lineReplacer.h" -void deleteLineFromFile(const char* file_name, int line, const char* new_line){ +void replaceLineInFile(const char* file_name, int line, const char* new_line){ FILE* file = fopen(file_name, "r"); if (file == NULL) { printf("Error opening file!\n"); @@ -39,10 +40,10 @@ void replaceBalanceInString(float replacementBalance, int currentLine) { char balance_as_string[MAX_LENGTH]; sprintf(balance_as_string, "%g", replacementBalance); //converts replacement balance to string strcat(newBalanceLine, balance_as_string); - deleteLineFromFile("CustomerData.txt",currentLine,newBalanceLine); + replaceLineInFile("CustomerData.txt",currentLine,newBalanceLine); } -bool updateAvailableAccountBalance(int user_id, float changeInBalance){ +bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool positive){ bool keep_reading = true; float availableBalance = 0; @@ -71,19 +72,19 @@ bool updateAvailableAccountBalance(int user_id, float changeInBalance){ fgets(buffer, MAX_LENGTH, file); strcpy(balance_String, buffer); currentLine+=4; - availableBalance = fetchBalanceFromBalanceString(balance_String); - + availableBalance = fetchBalanceFromBalanceString(balance_String); keep_reading = false; } } fclose(file); - replaceBalanceInString(availableBalance+changeInBalance,currentLine); + float newBalance = (positive) ? availableBalance+changeInBalance : availableBalance-changeInBalance; + replaceBalanceInString(newBalance,currentLine); } int main(){ - updateAvailableAccountBalance(1234,500); + updateAvailableAccountBalance(1234,500, true); return 0; } diff --git a/src/updateCustomerAccountBalance.h b/src/updateCustomerAccountBalance.h index 3a4d6da..4af3f89 100644 --- a/src/updateCustomerAccountBalance.h +++ b/src/updateCustomerAccountBalance.h @@ -4,6 +4,8 @@ #include #define MAX_LENGTH 100 -bool updateAvailableAccountBalance(int user_id, float changeInBalance); -void deleteLineFromFile(const char* file_name, int line, const char* new_line); + + +bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool positive); + void replaceBalanceInString(float replacementBalance, int currentLine); \ No newline at end of file