@ -5,7 +5,7 @@
bool isValidEmployeeID ( const char * employeeId , int maximumStringLength )
bool isValidEmployeeID ( const char * employeeId , int maximumStringLength )
{
{
int employeeIdLength = strlen ( employeeId ) ;
int employeeIdLength = strlen ( employeeId ) ;
/* looping through the employeeId string until a space is found to return false or true otherwise*/
for ( int i = 0 ; i < employeeIdLength ; i + + )
for ( int i = 0 ; i < employeeIdLength ; i + + )
{
{
if ( employeeId [ i ] = = ' ' )
if ( employeeId [ i ] = = ' ' )
@ -61,16 +61,9 @@ int StringLengthCounter(char* string)
return characterCounter ;
return characterCounter ;
}
}
bool verifyPassword ( char * enteredPassword , char * password Confirmation)
bool verifyPassword ( char * enteredPassword , char * Confirmation )
{
{
if ( strcmp ( enteredPassword , passwordConfirmation ) = = 0 )
{
return true ;
}
else
{
return false ;
}
return ! ( strcmp ( enteredPassword , Confirmation ) ) ;
}
}
@ -97,18 +90,18 @@ bool createNewEmployee(char* employeeId, char* employeePassword)
void getNewEmployeeCredentials ( )
void getNewEmployeeCredentials ( )
{
{
const int Length = 21 ;
char employeeId [ Length ] ;
const int minimum PasswordLength = 5 ;
char employeePassword [ Length ] ;
char passwordVerfication [ Length ] ;
const int max Length = 21 ;
char employeeId [ max Length] ;
const int minPasswordLength = 5 ;
char employeePassword [ max Length] ;
char passwordVerfication [ max Length] ;
printf ( " please enter your wished Id : \n " ) ;
printf ( " please enter your wished Id : \n " ) ;
/*Added the regular expression [^\n] so that the string keep on getting read until a newline '\n' is found*/
/*Added the regular expression [^\n] so that the string keep on getting read until a newline '\n' is found*/
scanf ( " %[^ \n ]s " , employeeId ) ;
scanf ( " %[^ \n ]s " , employeeId ) ;
employeeId [ Length ] = ' \0 ' ;
employeeId [ max Length] = ' \0 ' ;
printf ( " \n please enter your wished Password : \n " ) ;
printf ( " \n please enter your wished Password : \n " ) ;
@ -125,12 +118,12 @@ void getNewEmployeeCredentials()
if ( verifyPassword ( passwordVerfication , employeePassword ) )
if ( verifyPassword ( passwordVerfication , employeePassword ) )
{
{
if ( isValidEmployeeID ( employeeId , Length ) & & isValidPassword ( employeePassword , minimum PasswordLength ) )
if ( isValidEmployeeID ( employeeId , max Length) & & isValidPassword ( employeePassword , minPasswordLength ) )
{
{
createNewEmployee ( employeeId , employeePassword ) ? 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 " ) ;
createNewEmployee ( employeeId , employeePassword ) ? 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 " ) ;
}
}
else if ( isValidEmployeeID ( employeeId , Length ) & & ! isValidPassword ( employeePassword , minimum PasswordLength ) )
else if ( isValidEmployeeID ( employeeId , max Length) & & ! isValidPassword ( employeePassword , minPasswordLength ) )
{
{
printf ( " Error : the entered password should be at least 5 characters long and should contain at least 1 digit, 1 alphabet and 1 symbol! " ) ;
printf ( " Error : the entered password should be at least 5 characters long and should contain at least 1 digit, 1 alphabet and 1 symbol! " ) ;
}
}