diff --git a/src/LoginCustomer.c b/src/LoginCustomer.c index 5c2a7a4..8f3a760 100644 --- a/src/LoginCustomer.c +++ b/src/LoginCustomer.c @@ -1,4 +1,4 @@ -#include "LoginCustomer.h" +#include "loginCustomer.h" bool checkLogin(bool loginSuccessful) { diff --git a/src/LoginCustomer.h b/src/LoginCustomer.h index 809765b..e1c68e8 100644 --- a/src/LoginCustomer.h +++ b/src/LoginCustomer.h @@ -2,7 +2,7 @@ #include #include #include -#include "CustomerProperties.h" +#include "customerProperties.h" #define MAX_LOGIN_ATTEMPTS 3 char *generateCheckString(char *, char*); bool checkLogin(bool); diff --git a/src/a.exe b/src/a.exe deleted file mode 100644 index 7bbd2e2..0000000 Binary files a/src/a.exe and /dev/null differ diff --git a/src/updateCustomerAccountBalance.c b/src/updateCustomerAccountBalance.c index 6986e08..7cb7d3e 100644 --- a/src/updateCustomerAccountBalance.c +++ b/src/updateCustomerAccountBalance.c @@ -2,10 +2,29 @@ #include "currentCustomerAccountBalance.c" #include "lineReplacer.h" +void troubleShoot(int errorCode){ + printf("Error! The requested operation was terminated because of an issue. Here are some details about the error:\n---------------\n"); + + switch(errorCode){ + case 0: + printf("Requested file could not be opened. Are you sure it exists?"); + break; + case 1: + printf("A temporary file could not be generated. Are you sure the bank management system has the required authorization to create new files?"); + break; + case 2: + printf("Replacement of the old file failed. Are you sure the bank management system has the required authorization to delete files?"); + break; + case 3: + printf("Renaming of a file failed. Are you sure the bank management system has the required authorization to rename files?"); + break; + } +} + 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"); + troubleShoot(0); return; } char current_string[100]; @@ -14,7 +33,7 @@ void replaceLineInFile(const char* file_name, int line, const char* new_line){ temp_file_name = "temp.txt"; FILE* temp_file = fopen(temp_file_name, "w"); if (temp_file == NULL) { - printf("Error creating temp file!\n"); + troubleShoot(1); fclose(file); return; } @@ -30,10 +49,10 @@ void replaceLineInFile(const char* file_name, int line, const char* new_line){ fclose(file); fclose(temp_file); if(remove(file_name)!=0){ - printf("could not remove the original file!"); + troubleShoot(2); } // Remove the original file if(rename(temp_file_name, file_name)!=0){ - printf("could not rename!"); + troubleShoot(3); } // Rename the temp file to the original file } @@ -68,12 +87,11 @@ bool updateAvailableAccountBalance(int user_id, float newBalance){ keep_reading = false; } else if(strstr(buffer, stringID)) { //found the customer - fgets(buffer, MAX_LENGTH, file); - fgets(buffer, MAX_LENGTH, file); - fgets(buffer, MAX_LENGTH, file); - fgets(buffer, MAX_LENGTH, file); + for (int i = 0; i < 4; i++) { + fgets(buffer, MAX_LENGTH, file); + currentLine++; + } strcpy(balance_String, buffer); - currentLine+=4; keep_reading = false; }