Browse Source

solve merge conflicts.

remotes/origin/Alpha
fdai7207 2 years ago
parent
commit
555980d86a
  1. 39
      build-project.sh
  2. 15
      src/createEmployeeAccount.c
  3. 4
      src/employeeLogin.c
  4. 26
      src/employeesCredentialsList.txt
  5. 58
      src/employeesData.txt
  6. 26
      src/error.c
  7. BIN
      src/main
  8. 4
      src/mainMenu.c
  9. 3
      tests/test_createEmployeeAccount.c
  10. 8
      tests/test_mainMenu.c

39
build-project.sh

@ -1,3 +1,14 @@
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 clear
ceedling test:all ceedling test:all
rm -r build/ rm -r build/
@ -11,8 +22,36 @@ mv temp.txt employeesCredentialsList.txt
sed '/Name : John/,$d' employeesData.txt > temp.txt sed '/Name : John/,$d' employeesData.txt > temp.txt
mv temp.txt employeesData.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 gcc mainMenu.c error.c createEmployeeAccount.c showGeneralInfoEmployee.c employeeLogin.c createCustomer.c helperFunctions.c loginCustomer.c customerMenu.c main.c -o main
./main ./main
rm 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 .. cd ..

15
src/createEmployeeAccount.c

@ -1,5 +1,6 @@
#include "createEmployeeAccount.h" #include "createEmployeeAccount.h"
#include "employeeLogin.h"
bool isValidEmployeeID(const char* employeeId,const int maximumStringLength) bool isValidEmployeeID(const char* employeeId,const int maximumStringLength)
@ -200,19 +201,7 @@ void getNewEmployeeCredentials()
if(isValidName(data->firstName,minimumNameLength) && isValidName(data->lastName,minimumNameLength)) if(isValidName(data->firstName,minimumNameLength) && isValidName(data->lastName,minimumNameLength))
{ {
printf("\n\nplease enter your adress\n"); 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"); printf("\n\nplease enter your Phone number\n");
scanf(" %[^\n]s",data->phoneNumber); scanf(" %[^\n]s",data->phoneNumber);

4
src/employeeLogin.c

@ -1,5 +1,5 @@
#include "mainMenu.h"
#include "employeeLogin.h" #include "employeeLogin.h"
//#include "createEmployeeAccount.h"
#include "showGeneralInfoEmployee.h" #include "showGeneralInfoEmployee.h"
@ -16,7 +16,7 @@ int checkEmployeeCredentials(char *inputUsername, char *inputPassword)
char* listUsername = malloc(credentialLength * sizeof(char*)); char* listUsername = malloc(credentialLength * sizeof(char*));
char* listPassword = 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 ) if(employeeList == NULL )
{ {

26
src/employeesCredentialsList.txt

@ -39,3 +39,29 @@ Shivam Schivam007fdlt3781
210960 fdai7207.

58
src/employeesData.txt

@ -34,61 +34,3 @@ Adress : Fulda,leipzigerstrasse,6
Phone number : +4918756871384 Phone number : +4918756871384

26
src/error.c

@ -5,55 +5,55 @@ int errorMessage(int errorCode)
int returnValue=0; int returnValue=0;
switch(errorCode){ switch(errorCode){
case -1: case -1:
puts("Login not successful.");
//puts("Login not successful.");
returnValue = -1; returnValue = -1;
break; break;
case -2: case -2:
puts("Maximum number of attempts reached.");
//puts("Maximum number of attempts reached.");
returnValue = -2; returnValue = -2;
break; break;
case -3: case -3:
puts("No menu entry available for this number.");
//puts("No menu entry available for this number.");
returnValue = -3; returnValue = -3;
break; break;
case -4: 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; returnValue = -4;
break; break;
case -5: 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; returnValue = -5;
break; break;
case -6: 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; returnValue = -6;
break; break;
case -7: case -7:
puts("Forename too long. (length > 15 characters) Aborting!");
// puts("Forename too long. (length > 15 characters) Aborting!");
returnValue = -7; returnValue = -7;
break; break;
case -8: case -8:
puts("Surname too long. (length > 15 characters) Aborting!");
// puts("Surname too long. (length > 15 characters) Aborting!");
returnValue = -8; returnValue = -8;
break; break;
case -9: case -9:
puts("Password too long. (length > 20 characters) Aboring!");
// puts("Password too long. (length > 20 characters) Aboring!");
returnValue = -9; returnValue = -9;
break; break;
case -10: 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; returnValue = -10;
break; break;
case -11: 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; returnValue = -11;
break; break;
case -12: case -12:
puts("You entered too many digits.");
// puts("You entered too many digits.");
returnValue = -12; returnValue = -12;
break; break;
default: default:
puts("Error code unknown.");
// puts("Error code unknown.");
} }
return returnValue; return returnValue;
} }

BIN
src/main

4
src/mainMenu.c

@ -3,7 +3,7 @@
#include "createEmployeeAccount.h" #include "createEmployeeAccount.h"
#include "createCustomer.h" #include "createCustomer.h"
#include "error.h" #include "error.h"
#include "showGeneralInfoEmployee.h"
@ -122,9 +122,7 @@ void menuInput()
break; break;
case 4 : getNewEmployeeCredentials(); case 4 : getNewEmployeeCredentials();
printf("\nsee you next time !\n\n");
break; break;
case 5 : printf("\e[1;1H\e[2J"); case 5 : printf("\e[1;1H\e[2J");
printf("\nsee you next time !\n\n"); printf("\nsee you next time !\n\n");
break; break;

3
tests/test_createEmployeeAccount.c

@ -1,4 +1,3 @@
#ifdef TEST
#include "unity.h" #include "unity.h"
@ -303,5 +302,3 @@ void test_invalidPhoneNumber(void)
} }
#endif // TEST

8
tests/test_mainMenu.c

@ -3,6 +3,14 @@
#include "unity.h" #include "unity.h"
#include "../src/mainMenu.c" #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) void setUp(void)
{ {

Loading…
Cancel
Save