#include<iostream>
#include<string>
using namespace std;
const int maxe=100;
int top=0;
class employee{
public:
employee(string,string,int,int,int);
void setname(string,string);
void setdata(int,int,int);
void getname() const;
void getdata() const;
void printemployee() const;
private:
string firstname;
string lastname;
int day;
int year;
int month;
};
employee::employee(string wfirst,string wlast,int wmonth,int wday,int wyear)
{
setname(wfirst,wlast);
setdata(wmonth,wday,wyear);
top++;
}
void employee::setname(string wfirst,string wlast)
{
firstname=wfirst;
lastname=wlast;
}
void employee::setdata(int wmonth,int wday,int wyear)
{
month=wmonth;
day=wday;
year=wyear;
}
void employee::getname() const
{
cout<<"name : "<<firstname<<" "<<lastname<<endl;
}
void employee::getdata() const
{
cout<<"date :"<<month<<'/'<<day<<'/'<<year<<endl;
}
void employee::printemployee() const
{
getname();
getdata();
}
int main()
{
employee *ptr[maxe];
ptr[0]=new employee("xiao","min",11,21,1984);
ptr[1]=new employee("xiao","gang",9,23,1983);
int choice=1;
int i;
string ufirst;
string ulast;
int umonth;
int uyear;
int uday;
while(choice!=0)
{
cout <<endl<<endl<<"\t\t\t weclome to employee system \n\n\n";
cout <<"\t\t\t1.list\n\n\t\t\t2.add\n\n\t\t\t3.change\n\n\t\t\t4.leave"<<endl;
cin >>choice;
switch(choice)
{
case 1:
for(i=0;i<top;i++)
ptr[i]->printemployee();break;
case 2:
cout<<"please enter the employee.the firstname :";
cin>>ufirst;
cout<<" the lastname :";
cin>>ulast;
cout<<" the birthday.the month :";
cin>>umonth;
cout<<" the day :";
cin>>uday;
cout<<" the year :";
cin>>uyear;
int temp=top;
ptr[temp]=new employee(ufirst,ulast,umonth,uday,uyear);
break;
case 3:
cout<<"enter the full name.the firstname: ";
cin>>ufirst;
cout<<"the lastname: ";
cin>>ulast;
for(i=0;i<top;i++)
if(ufirst==ptr[i]->firstname && ulast==ptr[i]->lastname)
{
cout<<"1,change name\n2,change date\n";
cin>>choice;
switch(choice)
{
case 1: cout<<"enter the new name";
cin>>ufirst>>ulast;
ptr[i]->setname(ufirst,ulast);break;
case 2: cout<<"enter the new date";
cin>>umonth>>uday>>uyear;
ptr[i]->setdata(umonth,uday,uyear);break;
}
}
cout<<"no one here!!!!!"<<endl;break;
}
}
return 0;
}