diff --git a/build-project.sh b/build-project.sh index 98b90d6..f89e14e 100755 --- a/build-project.sh +++ b/build-project.sh @@ -1,5 +1,16 @@ +trap 'echo "Interrupted"; + rm main; + cp employeeLogin.c.bak employeeLogin.c; + cp mainMenu.c.bak mainMenu.c; + cp createEmployeeAccount.c.bak createEmployeeAccount.c; + rm employeeLogin.c.bak; + rm mainMenu.c.bak; + rm createEmployeeAccount.c.bak; + cd ..; + rm -r build; exit' SIGINT + clear -ceedling test:all +ceedling test:all rm -r build/ @@ -11,8 +22,36 @@ mv temp.txt employeesCredentialsList.txt sed '/Name : John/,$d' employeesData.txt > temp.txt mv temp.txt employeesData.txt +# backup files +for file in employeeLogin.c mainMenu.c createEmployeeAccount.c; do + cp "$file" "$file.bak" +done + +# replace .c with .h in respective files +#sed -i 's/createEmployeeAccount.c/createEmployeeAccount.h/g' mainMenu.c +#sed -i 's/showGeneralInfoEmployee.c/showGeneralInfoEmployee.h/g' employeeLogin.c +#sed -i 's/mainMenu.c/mainMenu.h/g' employeeLogin.c +#sed -i 's/employeeLogin.c/employeeLogin.h/g' createEmployeeAccount.c + +# remove 'src/' +for file in employeeLogin.c createEmployeeAccount.c; do + sed -i 's/src\///g' "$file" +done + + gcc mainMenu.c error.c createEmployeeAccount.c showGeneralInfoEmployee.c employeeLogin.c createCustomer.c helperFunctions.c loginCustomer.c customerMenu.c main.c -o main ./main rm main +# restore backups +for file in employeeLogin.c mainMenu.c createEmployeeAccount.c; do + cp "$file.bak" "$file" +done + +# remove backups +for file in employeeLogin.c.bak mainMenu.c.bak createEmployeeAccount.c.bak; do + rm "$file" +done + + cd .. diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index ac429e6..db75883 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -1,5 +1,6 @@ #include "createEmployeeAccount.h" +#include "employeeLogin.h" bool isValidEmployeeID(const char* employeeId,const int maximumStringLength) @@ -200,19 +201,7 @@ void getNewEmployeeCredentials() if(isValidName(data->firstName,minimumNameLength) && isValidName(data->lastName,minimumNameLength)) { printf("\n\nplease enter your adress\n"); - scanf(" %[^\n]s",street); - strcat(data->address,street); - - scanf(" %[^\n]s",city); - strcat(data->address,city); - - scanf("%d",houseNumber); - sprintf(houseNumberString,"%d",houseNumber); - strcat(data->address,houseNumberString); - - scanf("%s",postalCode); - sprintf(postalCodeString,"%d",postalCode); - strcat(data->address,postalCodeString); + scanf(" %[^\n]s",data->address); printf("\n\nplease enter your Phone number\n"); scanf(" %[^\n]s",data->phoneNumber); diff --git a/src/employeeLogin.c b/src/employeeLogin.c index 7c58fcf..3d70358 100644 --- a/src/employeeLogin.c +++ b/src/employeeLogin.c @@ -1,5 +1,5 @@ +#include "mainMenu.h" #include "employeeLogin.h" -//#include "createEmployeeAccount.h" #include "showGeneralInfoEmployee.h" @@ -16,7 +16,7 @@ int checkEmployeeCredentials(char *inputUsername, char *inputPassword) char* listUsername = malloc(credentialLength * sizeof(char*)); char* listPassword = malloc(credentialLength * sizeof(char*)); - FILE* employeeList = fopen("employeesCredentialsList.txt","r"); + FILE* employeeList = fopen("src/employeesCredentialsList.txt","r"); if(employeeList == NULL ) { diff --git a/src/employeesCredentialsList.txt b/src/employeesCredentialsList.txt index 3f2c0bf..e8b6ffb 100644 --- a/src/employeesCredentialsList.txt +++ b/src/employeesCredentialsList.txt @@ -39,3 +39,29 @@ Shivam Schivam007fdlt3781 + + + + + + + + + + + + + + + + + + + + + + + + +210960 fdai7207. + diff --git a/src/employeesData.txt b/src/employeesData.txt index cf51135..8c5d3ff 100644 --- a/src/employeesData.txt +++ b/src/employeesData.txt @@ -34,61 +34,3 @@ Adress : Fulda,leipzigerstrasse,6 Phone number : +4918756871384 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/error.c b/src/error.c index 481d268..1e41a8c 100644 --- a/src/error.c +++ b/src/error.c @@ -5,55 +5,55 @@ int errorMessage(int errorCode) int returnValue=0; switch(errorCode){ case -1: - puts("Login not successful."); + //puts("Login not successful."); returnValue = -1; break; case -2: - puts("Maximum number of attempts reached."); + //puts("Maximum number of attempts reached."); returnValue = -2; break; case -3: - puts("No menu entry available for this number."); + //puts("No menu entry available for this number."); returnValue = -3; break; case -4: - puts("CustomerData.* not found. Make sure that you've created an user account before logging in for the first time. Without users there is no file. Aborting!"); + //puts("CustomerData.* not found. Make sure that you've created an user account before logging in for the first time. Without users there is no file. Aborting!"); returnValue = -4; break; case -5: - puts("You should be at least 18 years old to create a bank account!"); + //puts("You should be at least 18 years old to create a bank account!"); returnValue = -5; break; case -6: - puts("Error when trying to open a file to create a customer account."); + // puts("Error when trying to open a file to create a customer account."); returnValue = -6; break; case -7: - puts("Forename too long. (length > 15 characters) Aborting!"); + // puts("Forename too long. (length > 15 characters) Aborting!"); returnValue = -7; break; case -8: - puts("Surname too long. (length > 15 characters) Aborting!"); + // puts("Surname too long. (length > 15 characters) Aborting!"); returnValue = -8; break; case -9: - puts("Password too long. (length > 20 characters) Aboring!"); + // puts("Password too long. (length > 20 characters) Aboring!"); returnValue = -9; break; case -10: - puts("You have entered an invalid character [ä,ö,ü, special characters] for your forename. This is not allowed. Aborting!"); + // puts("You have entered an invalid character [ä,ö,ü, special characters] for your forename. This is not allowed. Aborting!"); returnValue = -10; break; case -11: - puts("You have entered an invalid character [ä,ö,ü, special characters] for your surname. This is not allowed. Aborting!"); + // puts("You have entered an invalid character [ä,ö,ü, special characters] for your surname. This is not allowed. Aborting!"); returnValue = -11; break; case -12: - puts("You entered too many digits."); + // puts("You entered too many digits."); returnValue = -12; break; default: - puts("Error code unknown."); + // puts("Error code unknown."); } return returnValue; } diff --git a/src/main b/src/main deleted file mode 100755 index dae05f4..0000000 Binary files a/src/main and /dev/null differ diff --git a/src/mainMenu.c b/src/mainMenu.c index e1a16f8..0bbf39f 100644 --- a/src/mainMenu.c +++ b/src/mainMenu.c @@ -3,7 +3,7 @@ #include "createEmployeeAccount.h" #include "createCustomer.h" #include "error.h" -#include "showGeneralInfoEmployee.h" + @@ -122,9 +122,7 @@ void menuInput() break; case 4 : getNewEmployeeCredentials(); - printf("\nsee you next time !\n\n"); break; - case 5 : printf("\e[1;1H\e[2J"); printf("\nsee you next time !\n\n"); break; diff --git a/tests/test_createEmployeeAccount.c b/tests/test_createEmployeeAccount.c index b42ac75..410b0d9 100644 --- a/tests/test_createEmployeeAccount.c +++ b/tests/test_createEmployeeAccount.c @@ -1,4 +1,3 @@ -#ifdef TEST #include "unity.h" @@ -303,5 +302,3 @@ void test_invalidPhoneNumber(void) } - -#endif // TEST diff --git a/tests/test_mainMenu.c b/tests/test_mainMenu.c index 5ae1670..9bbaebe 100644 --- a/tests/test_mainMenu.c +++ b/tests/test_mainMenu.c @@ -3,6 +3,14 @@ #include "unity.h" #include "../src/mainMenu.c" +#include "../src/error.c" +#include "../src/loginCustomer.c" +#include "../src/helperFunctions.c" +#include "../src/createCustomer.c" +#include "../src/employeeLogin.c" +#include "../src/createEmployeeAccount.c" +#include "../src/customerMenu.c" +#include "../src/showGeneralInfoEmployee.c" void setUp(void) {