Showing posts with label cs304. Show all posts
Showing posts with label cs304. Show all posts

Friday, January 13, 2012

cs304 4 Object Oriented Programming Assignment Solution fall 2012

#include <iostream.h>
#include <string.h>
using namespace std;
class Cards{
      private:
              string id;
              string name;
      public:
            
             Cards();
             Cards(string,string);
             ~Cards();
             virtual void displayCards();
};
class Birth_Cards:public Cards
{
      private:
             
      public:
             virtual void displayCards();
             Birth_Cards();
             ~Birth_Cards();
};
class Marriage_Cards:public Cards
{
      private:
             
      public:
             virtual void displayCards();
             Marriage_Cards();
             ~Marriage_Cards();
};
class Friendship_Cards:public Cards
{
      private:
             
      public:
             virtual void displayCards();
             Friendship_Cards();
             ~Friendship_Cards();
};
//======================================
class Mehindi_Cards:public Marriage_Cards
{
      private:
             
      public:
             virtual void displayCards();
             Mehindi_Cards();
             ~Mehindi_Cards();
};
class Walima_Cards:public Marriage_Cards
{
      private:
             
      public:
             virtual void displayCards();
             Walima_Cards();
             ~Walima_Cards();
};
class Baraat_Cards:public Marriage_Cards
{
      private:
             
      public:
             virtual void displayCards();
             Baraat_Cards();
             ~Baraat_Cards();
};
//******************************************************************************
Cards::Cards()
{
}
Cards::Cards(string i,string n)
{
                    id=i;
                    name=n;
}
void Cards::displayCards()
{
     cout<<"You are now going to see the Cards"<<endl;
}
Cards::~Cards()
{
}
//=================================
Birth_Cards::Birth_Cards()
{
}
Birth_Cards::~Birth_Cards()
{
}
void Birth_Cards::displayCards()
{
     cout<<"You are now going to see the Birth Cards"<<endl;
}
//=================================
Marriage_Cards::Marriage_Cards()
{
}
Marriage_Cards::~Marriage_Cards()
{
}
void Marriage_Cards::displayCards()
{
     cout<<"You are now going to see the Marriage Cards"<<endl;
}
//=================================
Friendship_Cards::Friendship_Cards()
{
}
Friendship_Cards::~Friendship_Cards()
{
}
void Friendship_Cards::displayCards()
{
     cout<<"You are now going to see the Friendship Cards"<<endl;
}
//=================================
Mehindi_Cards::Mehindi_Cards()
{
}
Mehindi_Cards::~Mehindi_Cards()
{
}
void Mehindi_Cards::displayCards()
{
     cout<<"ID=123"<<endl;
     cout<<"Name=ABC"<<endl;
     cout<<"You are now going to see the Mehindi Cards"<<endl;
}
//=================================
Walima_Cards::Walima_Cards()
{
}
Walima_Cards::~Walima_Cards()
{
}
void Walima_Cards::displayCards()
{
     cout<<"ID=345"<<endl;
     cout<<"Name=XYZ"<<endl;
     cout<<"You are now going to see the Walima Cards"<<endl;
}
//=================================
Baraat_Cards::Baraat_Cards()
{
                       
}
Baraat_Cards::~Baraat_Cards()
{
}
void Baraat_Cards::displayCards()
{
     cout<<"ID=789"<<endl;
     cout<<"Name=PQR"<<endl;
     cout<<"You are now going to see the Baraat Cards"<<endl;
}
//=================================
//******************************************************************************
main()
{
     
      Cards *c=new Cards;
      c->displayCards();
      Cards *d=new Birth_Cards;
      d->displayCards();
      Cards *e=new Marriage_Cards;
      e->displayCards();
      Cards *f=new Friendship_Cards;
      f->displayCards();
      Cards *g=new Mehindi_Cards;
      g->displayCards();
      Cards *h=new Walima_Cards;
      h->displayCards();
      Cards *i=new Baraat_Cards;
      i->displayCards();
     
      system("pause");
}

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();
     
}