@ -16,6 +16,38 @@ int StringLengthCounter(char* string)
return characterCounter ;
return characterCounter ;
}
}
bool isValidPassword ( char * employeePassword , int minimumStringLength )
{
char * stringpointer = employeePassword ;
int employeePasswordLength = 0 ;
bool letterFound = false , punctuationFound = false , numberFound = false ;
while ( * stringpointer ! = ' \0 ' )
{
if ( isalpha ( * stringpointer ) )
{
letterFound = true ;
}
else if ( isdigit ( * stringpointer ) )
{
numberFound = true ;
}
else if ( ispunct ( * stringpointer ) )
{
punctuationFound = true ;
}
if ( employeePasswordLength > = minimumStringLength & & letterFound & & numberFound & & punctuationFound )
{
return true ;
}
+ + stringpointer ;
+ + employeePasswordLength ;
}
return false ;
}
bool isValidEmployeeID ( const char * employeeId , int maximumStringLength )
bool isValidEmployeeID ( const char * employeeId , int maximumStringLength )
{
{
@ -54,9 +86,10 @@ bool createNewEmployee(char* employeeId, char* employeePassword)
void getNewEmployeeCredentials ( )
void getNewEmployeeCredentials ( )
{
{
const int employeeIdlength = 21 ;
char employeeId [ employeeIdlength ] ;
char employeePassword [ employeeIdlength ] ;
const int employeeIdLength = 21 ;
char employeeId [ employeeIdLength ] ;
const int minimumPasswordLength = 5 ;
char employeePassword [ minimumPasswordLength ] ;
printf ( " please enter your wished Id : \n " ) ;
printf ( " please enter your wished Id : \n " ) ;
@ -64,15 +97,15 @@ void getNewEmployeeCredentials()
scanf ( " %[^ \n ]s " , employeeId ) ;
scanf ( " %[^ \n ]s " , employeeId ) ;
employeeId [ employeeIdl ength ] = ' \0 ' ;
employeeId [ employeeIdL ength ] = ' \0 ' ;
printf ( " \n please enter your wished Password : \n " ) ;
printf ( " \n please enter your wished Password : \n " ) ;
scanf ( " %s " , employeePassword ) ;
scanf ( " %s " , employeePassword ) ;
employeePassword [ employeeIdlength ] = ' \0 ' ;
employeePassword [ strlen ( employeePassword ) ] = ' \0 ' ;
if ( isValidEmployeeID ( employeeId , employeeIdl ength ) )
if ( isValidEmployeeID ( employeeId , employeeIdL ength ) )
{
{
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 " ) ;
}
}