I have only been programming for about 7 weeks now and our current assignment is enormous. We have to make an Admin Interface that asks for a login and then verifies it. Then we have to show a full line up of options and do those as well. If anyone could help me with the admin login part it would be greatly appreciated. Here is the part I am not sure how to do.
There are supposed to be two seperate functions.
• ValidateAdmin
o This function receives the id and password, and validate if the id-password pair is valid
o If the id-password is valid, a true value is returned. Otherwise, a false value is returned instead
• AdminLogin 巳
o Prompt and accept a admin’s ID and password, and return this information to the calling function
o The ID and password returned to the calling function must be valid
o In case of the invalid ID-password pair entered, an error message must be displayed and a new input is prompted until a valid ID/password pair is provided
This is my code for them.....Any input would be great.
Code:
bool ValidateAdmin() {
ifstream AdminIn;
string Id, Password, admin;
AdminIn.open(admin.c_str(), ios::in);
getline(AdminIn, Id);
while(!AdminIn.eof()) {
getline(AdminIn, Password);
//clear screen and return to main menu.
getline(AdminIn, Id);
}
if(Id !=Password){
cout<<"Invalid user Id and password combination!";
exit(1);
}
if(Id = EnterId && password = EnterPassword){
ValidateAdmin = true
else ValidateAdmin = false;
}
return ValidateAdmin;
}
string AdminLogin {
string EnterId, EnterPassword;
cout<<"***** ADMIN LOGIN *****";
cout<<endl;
cout<<endl;
cout<<"Enter user ID:";
cin<<EnterId;
cout<<"Enter a password:";
cin<<EnterPassword;
return EnterId;
return EnterPassword;
What way should I be doing this to match the way he is explaining it?