Browse Source

refactoring: changed some variable names and implemented if statements in showGeneralInfoEmployee.c

remotes/origin/feature/show-general-info-employee
fdai7514 2 years ago
parent
commit
0298030b9f
  1. 86
      src/showGeneralInfoEmployee.c

86
src/showGeneralInfoEmployee.c

@ -1,31 +1,38 @@
#include "showGeneralInfoEmployee.h"
//a = employeeName b = password
int checkUser(char a[length], char b[length])
//int checkUser() is helpful for unittesting showGeneralInfoEmployee()
int checkUser(char username[length], char password[length])
{
if(strcmp(a,"Atharva")==0 && strcmp(b,"Atharva")==0)
{
return 1;
}
else if(strcmp(a,"Can")==0 && strcmp(b,"BlooMask")==0)
{
return 2;
}
else if(strcmp(a,"Haytham")==0 && strcmp(b,"TimoDL")==0)
{
return 3;
}
else if(strcmp(a,"Julius")==0 && strcmp(b,"Insertcat")==0)
{
return 4;
}
else if(strcmp(a,"Mohamed")==0 && strcmp(b,"MD")==0)
{
return 5;
}
else if(strcmp(a,"Shivam")==0 && strcmp(b,"Schivam007")==0)
{
return 6;
}
if(strcmp(username,"Atharva")==0 && strcmp(password,"Atharva")==0)
{
return 1;
}
if(strcmp(username,"Can")==0 && strcmp(password,"BlooMask")==0)
{
return 2;
}
if(strcmp(username,"Haytham")==0 && strcmp(password,"TimoDL")==0)
{
return 3;
}
if(strcmp(username,"Julius")==0 && strcmp(password,"Insertcat")==0)
{
return 4;
}
if(strcmp(username,"Mohamed")==0 && strcmp(password,"MD")==0)
{
return 5;
}
if(strcmp(username,"Shivam")==0 && strcmp(password,"Schivam007")==0)
{
return 6;
}
else
{
return 0;
@ -33,10 +40,11 @@ int checkUser(char a[length], char b[length])
}
void showGeneralInfoEmployee(char id[length], char p[length])
void showGeneralInfoEmployee(char id[length], char password[length])
{
// "If Statements" check, whether the id and the password match
if(checkUser(id, p) == 1)
// "If Statements" check, whether the username and password match.
if(checkUser(id, password) == 1)
{
printf(" Welcome Atharva\n");
printf(" Clearance: 3\n");
@ -44,7 +52,8 @@ void showGeneralInfoEmployee(char id[length], char p[length])
printf("\n");
printf(" ->Review new customer applications.\n");
}
if(checkUser(id, p) == 2)
if(checkUser(id, password) == 2)
{
printf(" Welcome Can\n");
printf(" Clearance: 3\n");
@ -52,7 +61,8 @@ void showGeneralInfoEmployee(char id[length], char p[length])
printf("\n");
printf(" ->Review new customer applications.\n");
}
if(checkUser(id, p) == 3)
if(checkUser(id, password) == 3)
{
printf(" Welcome Haytham\n");
printf(" Clearance: 2\n");
@ -61,7 +71,8 @@ void showGeneralInfoEmployee(char id[length], char p[length])
printf(" ->Review new customer applications.\n");
printf(" ->Review loan applications.\n");
}
if(checkUser(id, p) == 4)
if(checkUser(id, password) == 4)
{
printf(" Welcome Julius\n");
printf(" Clearance: 2\n");
@ -70,7 +81,8 @@ void showGeneralInfoEmployee(char id[length], char p[length])
printf(" ->Review new customer applications.\n");
printf(" ->Review loan applications.\n");
}
if(checkUser(id, p) == 5)
if(checkUser(id, password) == 5)
{
printf(" Welcome Mohamed\n");
printf(" Clearance: 3\n");
@ -80,7 +92,8 @@ void showGeneralInfoEmployee(char id[length], char p[length])
printf(" ->Review loan applications.\n");
printf(" ->Terminate account.\n");
}
if(checkUser(id, p) == 6)
if(checkUser(id, password) == 6)
{
printf(" Welcome Shivam\n");
printf(" Clearance: 3\n");
@ -90,10 +103,5 @@ void showGeneralInfoEmployee(char id[length], char p[length])
printf(" ->Review loan applications.\n");
printf(" ->Terminate account.\n");
}
else
{
}
}
Loading…
Cancel
Save