From d5952a55bf49536e07548add3f74b03e71fc1de2 Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Wed, 8 Feb 2023 00:37:00 +0100 Subject: [PATCH] refactoring: removed some constants from the .c file and added them to the header file and made the isValidName() function more readable. --- src/createEmployeeAccount.c | 21 ++++++++------------- src/createEmployeeAccount.h | 4 ++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index db149f8..3fb19e5 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -2,7 +2,7 @@ #include "createEmployeeAccount.h" -bool isValidEmployeeID(const char* employeeId, int maximumStringLength) +bool isValidEmployeeID(const char* employeeId,const int maximumStringLength) { int employeeIdLength = strlen(employeeId); /* looping through the employeeId string until a space is found to return false or true otherwise*/ @@ -17,7 +17,7 @@ bool isValidEmployeeID(const char* employeeId, int maximumStringLength) } -bool isValidPassword( char *password, int minimumLength) +bool isValidPassword( char *password,const int minimumLength) { /*created a pointer(*stringpointer) which helps loop through characters of the string password*/ char *stringpointer = password; @@ -48,20 +48,21 @@ bool isValidPassword( char *password, int minimumLength) } -bool isValidName(char* name, int minimalLength) +bool isValidName(char* name,const int minimalLength) { - if(strlen(name) < minimalLength) + int nameLength = strlen(name); + if(nameLength < minimalLength) { return false; } - for(int i = 0;i #include +#define minPasswordLength 5 +#define minimumNameLength 4 +#define maxLength 21 + struct employeesInformations { char firstName[15];