From e570fb9f66b2f7edc9ee8ffe13436bd9e46223a4 Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Sat, 4 Feb 2023 04:12:39 +0100 Subject: [PATCH] refactoring: changed some variables names and added some comments for documentation and enhanced the getnewEmployeeCredentials function. --- src/createEmployeeAccount.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index 92f0f90..ac1a26a 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -20,18 +20,19 @@ bool isValidEmployeeID(char* employeeId) bool createNewEmployee(char* employeeId, char* employeePassword) { - FILE* employeesList; - employeesList = fopen("src/employeeList.txt","a"); + FILE* employeesFile; + employeesFile = fopen("src/employeeList.txt","a"); - if(employeesList == NULL) + if(employeesFile == NULL) { - printf("Error: could not open the list of Employees"); + printf("Error: could not find the list of Employees"); return false; } - fprintf(employeesList,"\n%s %s\n",employeeId,employeePassword); - fclose(employeesList); + fprintf(employeesFile,"\n%s %s\n",employeeId,employeePassword); + fclose(employeesFile); +/*used the checkEmployeeCredentials to check if the new id and password are created successfully*/ return checkEmployeeCredentials(employeeId, employeePassword); } @@ -46,12 +47,6 @@ void getNewEmployeeCredentials() printf("please enter your wished Password :"); scanf("%s",newEmployeePassword); - if(createNewEmployee(newEmployeeId,newEmployeePassword)) - { - printf("\n\n Account created successfully !\n\n"); - } - else - { - printf("\n\n Could not create the Account please contact an employee of clearance 1 !\n\n"); - } + createNewEmployee(newEmployeeId,newEmployeePassword) ? printf("\n\n Account created successfully !\n\n") : printf("\n\n Could not create the Account please contact an employee of clearance 1 !\n\n"); + }