Thursday, March 4, 2010
0
Lab oop Answer
Have you done this lab, if not here i will provide the answer for you to study it first and do your own source code, not just copy and paste. I help you and you must help me. Below is the source code: Please separate the header file, implementation and main function.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include
using namespace std;
class Employee
{
private:
string name;
int id;
public:
Employee(string,int);
void setName (string);
string getName ();
void setId (int);
int getId ();
void show_info ();
};
#endif
#include
#include
#include "Employee.h"
using namespace std;
Employee::Employee(string NM, int ID)
{
setName (NM);
setId (ID);
}
void Employee::setName (string NM)
{
name = NM;
}
string Employee::getName()
{
return name;
}
void Employee::setId (int ID)
{
id = ID;
}
int Employee::getId ()
{
return id;
}
void Employee::show_info ()
{
cout << "Name = " << getName() << endl;
cout << "Id = " << getId () << endl;
}
#ifndef CUSTOMER_H
#define CUSTOMER_H
#include
#include "Employee.h"
using namespace std;
class Customer : public Employee
{
private:
string custname;
int custid;
public:
Customer (string,int,string,int);
void setCustname (string);
string getCustname ();
void setCustid (int);
int getCustid ();
void show_info ();
};
#endif
#include
#include
#include "Employee.h"
#include "Customer.h"
using namespace std;
Customer::Customer(string CNM,int CID,string NM,int ID)
:Employee(NM,ID)
{
setCustname (CNM);
setCustid (ID);
}
void Customer::setCustname (string NM)
{
custname = NM;
}
string Customer::getCustname ()
{
return custname;
}
void Customer::setCustid (int ID)
{
custid = ID;
}
int Customer::getCustid ()
{
return custid;
}
void Customer::show_info ()
{
Employee::show_info();
cout << "Customer Name = " << getCustname() << endl;
cout << "Customer Id = " << getCustid() << endl;
cout << "\n\n";
}
#ifndef RETAILER_H
#define RETAILER_H
#include
#include "Employee.h"
using namespace std;
class Retailer : public Employee
{
private:
string retname;
int retid;
public:
Retailer (string,int,string,int);
void setRetname (string);
string getRetname ();
void setRetid (int);
int getRetid ();
void show_info ();
};
#endif
#include
#include
#include "Employee.h"
#include "Retailer.h"
using namespace std;
Retailer::Retailer (string RNM,int RID,string NM,int ID)
:Employee (NM,ID)
{
setRetname(RNM);
setRetid(RID);
}
void Retailer::setRetname(string NM)
{
retname = NM;
}
string Retailer::getRetname()
{
return retname;
}
void Retailer::setRetid (int ID)
{
retid = ID;
}
int Retailer::getRetid()
{
return retid;
}
void Retailer::show_info()
{
Employee::show_info();
cout << "Retailer Name = " << getRetname() << endl;
cout << "Retailer Id = " << getRetid() << endl;
cout << "\n\n";
}
#include
#include
#include "Customer.h"
#include "Retailer.h"
using namespace std;
int main()
{
Customer c1("Hilmi Idris",1231,"Shairazey",3455);
c1.show_info();
Retailer r1("Mohd Izzat",4455,"Bazli Aghniya",8877);
r1.show_info();
return 0;
}
Ok. Thats all. If you have any problem or any error occurs. Please contact me immediately, but i am sure no error. Thank you.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include
using namespace std;
class Employee
{
private:
string name;
int id;
public:
Employee(string,int);
void setName (string);
string getName ();
void setId (int);
int getId ();
void show_info ();
};
#endif
#include
#include
#include "Employee.h"
using namespace std;
Employee::Employee(string NM, int ID)
{
setName (NM);
setId (ID);
}
void Employee::setName (string NM)
{
name = NM;
}
string Employee::getName()
{
return name;
}
void Employee::setId (int ID)
{
id = ID;
}
int Employee::getId ()
{
return id;
}
void Employee::show_info ()
{
cout << "Name = " << getName() << endl;
cout << "Id = " << getId () << endl;
}
#ifndef CUSTOMER_H
#define CUSTOMER_H
#include
#include "Employee.h"
using namespace std;
class Customer : public Employee
{
private:
string custname;
int custid;
public:
Customer (string,int,string,int);
void setCustname (string);
string getCustname ();
void setCustid (int);
int getCustid ();
void show_info ();
};
#endif
#include
#include
#include "Employee.h"
#include "Customer.h"
using namespace std;
Customer::Customer(string CNM,int CID,string NM,int ID)
:Employee(NM,ID)
{
setCustname (CNM);
setCustid (ID);
}
void Customer::setCustname (string NM)
{
custname = NM;
}
string Customer::getCustname ()
{
return custname;
}
void Customer::setCustid (int ID)
{
custid = ID;
}
int Customer::getCustid ()
{
return custid;
}
void Customer::show_info ()
{
Employee::show_info();
cout << "Customer Name = " << getCustname() << endl;
cout << "Customer Id = " << getCustid() << endl;
cout << "\n\n";
}
#ifndef RETAILER_H
#define RETAILER_H
#include
#include "Employee.h"
using namespace std;
class Retailer : public Employee
{
private:
string retname;
int retid;
public:
Retailer (string,int,string,int);
void setRetname (string);
string getRetname ();
void setRetid (int);
int getRetid ();
void show_info ();
};
#endif
#include
#include
#include "Employee.h"
#include "Retailer.h"
using namespace std;
Retailer::Retailer (string RNM,int RID,string NM,int ID)
:Employee (NM,ID)
{
setRetname(RNM);
setRetid(RID);
}
void Retailer::setRetname(string NM)
{
retname = NM;
}
string Retailer::getRetname()
{
return retname;
}
void Retailer::setRetid (int ID)
{
retid = ID;
}
int Retailer::getRetid()
{
return retid;
}
void Retailer::show_info()
{
Employee::show_info();
cout << "Retailer Name = " << getRetname() << endl;
cout << "Retailer Id = " << getRetid() << endl;
cout << "\n\n";
}
#include
#include
#include "Customer.h"
#include "Retailer.h"
using namespace std;
int main()
{
Customer c1("Hilmi Idris",1231,"Shairazey",3455);
c1.show_info();
Retailer r1("Mohd Izzat",4455,"Bazli Aghniya",8877);
r1.show_info();
return 0;
}
Ok. Thats all. If you have any problem or any error occurs. Please contact me immediately, but i am sure no error. Thank you.
Subscribe to:
Post Comments (Atom)
0 Responses to “Lab oop Answer”
Post a Comment