G
gonzal51
Hi, I'm a student learning C++ and my professor isn't much help, her view is
if you dont get it I ain't helping you....
We are supposed to do a basic program as a logon system. I got as far as I
could and came up with some errors I could not understand.
Any Help would be appreciated.
Using: MS Visual Studio .Net 2003
Language: C++
Program centers around: Classes
**CODE**
/*
Name: Matthew Gonzalez
Prog Name: gonzalez_PA10
Date: 4/27/05
Purpose: Classes
*/
#include <iostream>
using namespace std;
//class
class User
{
private:
int userId;
char firstName[20];
char lastName[20];
char password[20];
public:
void setUserData(char firstName[20],char lastName[20],char password[20]);
void changePassword (char password[20],char newPass[20]);
void displayUser(int userId,char firstName[20],char lastName[20], char
password[20]);
};
//end class
User::setUserData(char firstName[20],char lastName[20],char password[20])
{
cout<<"Please Enter Your First Name: "<<endl;
cin>>firstName[20];
cout<<"Please Enter your Last Name: "<<endl;
cin>>lastName[20];
cout<<"Please Enter your Password: "<<endl;
cin>>password[20];
//end setuserdatafunction
}
User::changePassword(char password[20],char newPass[20])
{
cout<<"Please enter new password"<<endl;
cin>>newPass[20];
if(password[20]==newPass[20])
{
cout<<"Your password is the same. No Change will occur."<<endl;
}
else
{
if(password[20]!=newPass[20])
newPass[20]=password[20];
}
}
User::displayUser(int userId,char firstName[20],char lastName[20], char
password[20])
{
cout<<"The User id is: "<<userId<<endl;
cout<<"The First name is: "<<firstName[20]<<endl;
cout<<"The Last name is: "<<lastName[20]<<endl;
cout<<"The password is: "<<password[20]<<endl;
//end display user function
}
int main()
{
//user object
User logon;
int userId;
char firstName[20];
char lastName[20];
char password[20];
char newPass[20];
char answer;
cout<<"Please enter a user Id: "<<endl;
cin>>userId;
logon.setUserData(char firstName[20],char lastName[20],char password[20]);
cout<<"Do you want to change your password? Enter Y or N: "<<endl;
cin>>answer;
//if
if(answer=='y')
{
logon.changePassword(char password[20],char newPass[20]);
logon.displayUser(int UserId,char firstName[20],char lastName[20],char
password[20]);
}
else
if(answer=='n')
{
logon.displayUser(int UserId,char firstName[20],char lastName[20],char
password[20]);
}
//endif
return 0;
}
**END CODE**
if you dont get it I ain't helping you....
We are supposed to do a basic program as a logon system. I got as far as I
could and came up with some errors I could not understand.
Any Help would be appreciated.
Using: MS Visual Studio .Net 2003
Language: C++
Program centers around: Classes
**CODE**
/*
Name: Matthew Gonzalez
Prog Name: gonzalez_PA10
Date: 4/27/05
Purpose: Classes
*/
#include <iostream>
using namespace std;
//class
class User
{
private:
int userId;
char firstName[20];
char lastName[20];
char password[20];
public:
void setUserData(char firstName[20],char lastName[20],char password[20]);
void changePassword (char password[20],char newPass[20]);
void displayUser(int userId,char firstName[20],char lastName[20], char
password[20]);
};
//end class
User::setUserData(char firstName[20],char lastName[20],char password[20])
{
cout<<"Please Enter Your First Name: "<<endl;
cin>>firstName[20];
cout<<"Please Enter your Last Name: "<<endl;
cin>>lastName[20];
cout<<"Please Enter your Password: "<<endl;
cin>>password[20];
//end setuserdatafunction
}
User::changePassword(char password[20],char newPass[20])
{
cout<<"Please enter new password"<<endl;
cin>>newPass[20];
if(password[20]==newPass[20])
{
cout<<"Your password is the same. No Change will occur."<<endl;
}
else
{
if(password[20]!=newPass[20])
newPass[20]=password[20];
}
}
User::displayUser(int userId,char firstName[20],char lastName[20], char
password[20])
{
cout<<"The User id is: "<<userId<<endl;
cout<<"The First name is: "<<firstName[20]<<endl;
cout<<"The Last name is: "<<lastName[20]<<endl;
cout<<"The password is: "<<password[20]<<endl;
//end display user function
}
int main()
{
//user object
User logon;
int userId;
char firstName[20];
char lastName[20];
char password[20];
char newPass[20];
char answer;
cout<<"Please enter a user Id: "<<endl;
cin>>userId;
logon.setUserData(char firstName[20],char lastName[20],char password[20]);
cout<<"Do you want to change your password? Enter Y or N: "<<endl;
cin>>answer;
//if
if(answer=='y')
{
logon.changePassword(char password[20],char newPass[20]);
logon.displayUser(int UserId,char firstName[20],char lastName[20],char
password[20]);
}
else
if(answer=='n')
{
logon.displayUser(int UserId,char firstName[20],char lastName[20],char
password[20]);
}
//endif
return 0;
}
**END CODE**