Thursday, December 29, 2011

cs304 3 object oriented programming

#include <iostream.h>
#include <conio.h>
#include <string.h>
using namespace std;
class view;
class User;
class Members;
class Administrator;
class MemberList;
class Card;
class CategoryCatology;

class User{
      private:                
            
             
              string id;
              string name;
              string Address;
             
      public:
             void setId();
             string getId(); 
             void setName();
             string getName();
             void setAddress();
             string getAddress();           
             void viewCard();
             void searchCard(string);
             void verifyUser();
};

           
class Administrator: public User{
      private:                 
             
             
              int AdminID;
              char *name;
              char *address;
              MemberList *passward;
              CategoryCatology *catID; 
     
      public:                
             
             void AddCard();
             void DeleteCard();
             void SendCard();
             void CustomizedCard();
             void verifyUser();
};
                   
class Members: public User{  
     
      private:                  
             char *MemberID;
              char *address;
              MemberList *memberName;
             
      public:                             
             void SendCard();
             void CustomizedCard();
             void verifyUser();
};


//==================defination of functions of user class====================
void User::setId()
{
     string i;
     cout<<"Please enter the Id:"<<endl;
     cin>>i;
     id=i;
}
void User::setName()
{
     string s;
     cout<<"Please enter the Name:"<<endl;
     cin>>s;
     name=s;
}
void User::setAddress()
{
     string s;
     cout<<"Please enter the Address:"<<endl;
     cin>>s;
     Address=s;
}
string User::getId()
{
     return id;
}
string User::getAddress()
{
       return Address;
}
string User::getName()
{
       return name;
}
void User::viewCard()
{
     cout<<"cards are displayed"<<endl;
}
void User::searchCard(string c)
{
     cout<<c<<" is searched:"<<endl;
}
void User::verifyUser()
{
     cout<<getName()<<"is a user. "<<endl;
}
//==================defination of functions of admin class====================
void Administrator::AddCard()
{
     string c;
     cout<<"Please enter the name of the Card: ";
     cin>>c;
     cout<<c<<" card is added."<<endl;
}
void Administrator::DeleteCard()
{
     string c;
     cout<<"Please enter the name of the Card: ";
     cin>>c;
     cout<<c<<" card is deleted."<<endl;
}
void Administrator::SendCard()
{
     string c;
     cout<<"Please enter the name of the Card: ";
     cin>>c;
     cout<<c<<" card is sended."<<endl;
}
void Administrator::CustomizedCard()
{
     string c;
     cout<<"Please enter the name of the Card: ";
     cin>>c;
     cout<<c<<" card is Customized."<<endl;
}
void Administrator::verifyUser()
{
     cout<<getName()<<"is an Administrator. "<<endl;
}

//==================defination of functions of Members class====================

void Members::SendCard()
{
     string c;
     cout<<"Please enter the name of the Card: ";
     cin>>c;
     cout<<c<<" card is sended."<<endl;
}
void Members::CustomizedCard()
{
     string c;
     cout<<"Please enter the name of the Card: ";
     cin>>c;
     cout<<c<<" card is Customized."<<endl;
}
void Members::verifyUser()
{
     cout<<getName()<<"is a Member. "<<endl;
}
//=============================================================================
class View
{
      private:
             
      public:
             User u;
             Administrator a;
              Members m;
             void userop()
             {
                  char c;
                  cout<<"yor are a USER"<<endl;
                  cout<<u.getName()<<endl;
                  cout<<u.getAddress()<<endl;
                  cout<<u.getId()<<endl;
                  while(true)
                  {
                  cout<<"Please select a operation:"<<endl;
                  cout<<"v    for   verifyuser";
                  cin>>c;
                  u.verifyUser();
                  }
             }
             void adminop()
             {}
             void memop()
             {}
             void login()
             {
                  char usr;
                  cout<<"Please enter the user name from the givin:"<<endl;
                  cout<<"u    for   user\na    for   Admin\nm    for   member"<<endl;
                  cin>>usr;
                  if(usr == 'u')
                  {
                         User u;
                         u.setName();
                         u.setId();
                         u.setAddress();
                         userop();
                  }
                  if(usr == 'a')
                  {
                        
                         a.setName();
                         a.setId();
                         a.setAddress();
                         adminop();
                  }
                  if(usr == 'm')
                  {
                       
                         m.setName();
                         m.setId();
                         m.setAddress();
                         memop();
                  }
                 
             }
};
            

main()
{
     View v;
     v.login();
     
}
     

No comments:

Post a Comment