Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include< iostream >
- #include< string >
- using namespace std;
- //defining class Employee
- class Employee
- {
- private:string EmpName;
- int EmpNumber;
- string Hiredate;
- //Default constructor
- public: Employee()
- {
- EmpName = " ";
- EmpNumber = 0;
- Hiredate = " ";
- }
- //Parameterized constructor
- Employee(string name, int number, string date)
- {
- EmpName = name;
- EmpNumber = number;
- Hiredate = date;
- }
- //Member functions
- void setEmpName(string);
- void setEmpNumber(int);
- void setHireDate(string);
- string getEmpName();
- int getEmpNumber();
- string getHireDate();
- };
- //Defining member functions
- void Employee::setEmpName(string str)
- {
- EmpName = str;
- }//end setEmpName
- void Employee::setEmpNumber(int num)
- {
- EmpNumber = num;
- }//end setEmpNumber
- void Employee::setHireDate(string date)
- {
- Hiredate = date;
- }//end setHireDate
- string Employee::getEmpName()
- {
- return EmpName;
- }//end getEmpName
- int Employee::getEmpNumber()
- {
- return EmpNumber;
- }//end getEmpNumber
- string Employee::getHireDate()
- {
- return Hiredate;
- }//end getHireDate
- //defining derived class ProductionWorker
- class ProductionWorker :public Employee
- {
- private:int Shift;
- double HourlyPay;
- //Default constructor
- public: ProductionWorker()
- {
- Shift = 0;
- HourlyPay = 0;
- }
- //Parameterized constructor
- ProductionWorker(int sh, double pay)
- {
- Shift = sh;
- HourlyPay = pay;
- }
- void setShift(int);
- void setHourlyPay(double);
- int getShift();
- double getHourlyPay();
- };
- //Defining member functions
- void ProductionWorker::setShift(int sh)
- {
- Shift = sh;
- }//end setShift
- void ProductionWorker::setHourlyPay(double pay)
- {
- HourlyPay = pay;
- }//end setHourlyPay
- int ProductionWorker::getShift()
- {
- return Shift;
- }//end getShift
- double ProductionWorker::getHourlyPay()
- {
- return HourlyPay;
- }//end getHourlyPay
- class TeamLeader :public ProductionWorker
- {
- private: double MonthlyBonus;
- //variable to hold number of training hours required
- int TRequiredHours;
- //variable to hold number of training hours attended
- int TAttendHours;
- public: //Default constructors
- TeamLeader()
- {
- MonthlyBonus = 0.0;
- TRequiredHours = 0;
- TAttendHours = 0;
- }
- //Parameterized constructors
- TeamLeader(double MBonus, int TRhours, int TAhours)
- {
- MonthlyBonus = MBonus;
- TRequiredHours = TRhours;
- TAttendHours = TAhours;
- }
- void setMonthlyBonus(double);
- void setTRequiredHours(int);
- void setTAttendHours(int);
- double getMonthlyBonus();
- int getTRequiredHours();
- int getTAttendHours();
- };
- //Function definitions
- void TeamLeader::setMonthlyBonus(double MBonus)
- {
- MonthlyBonus = MBonus;
- }
- //end setMonthlyBonus
- void TeamLeader::setTAttendHours(int Ahours)
- {
- TAttendHours = Ahours;
- }//end setTAttendHours
- void TeamLeader::setTRequiredHours(int Rhours)
- {
- TRequiredHours = Rhours;
- }//end setTRequiredHours
- double TeamLeader::getMonthlyBonus()
- {
- return MonthlyBonus;
- }//end getMonthlyBonus
- int TeamLeader::getTAttendHours()
- {
- return TAttendHours;
- }//end getTAttendHours
- int TeamLeader::getTRequiredHours()
- {
- return TRequiredHours;
- }//end getTRequiredHours
- void main()
- {
- TeamLeader lead1;
- int shift;
- double pay;
- int requiredHours, attendHours, Mbonus;
- //Inputting data
- lead1.setEmpName("Winston");
- lead1.setEmpNumber(562);
- lead1.setHireDate(" June:11");
- cout << " 1-DayShift \n 2-Night" << endl;
- cout << "Enter shift:";
- cin >> shift;
- cout << "Enter hourly pay:";
- cin >> pay;
- lead1.setShift(shift);
- lead1.setHourlyPay(pay);
- cout << "Enter Montly Bonus:";
- cin >> Mbonus;
- cout << "Enter Required Hours:";
- cin >> requiredHours;
- lead1.setTRequiredHours(requiredHours);
- cout << "Enter Attended hours:";
- cin >> attendHours;
- lead1.setTAttendHours(attendHours);
- //Outputting Data
- cout << "-----Team Lead Details-----" << endl;
- cout << "Name:" << lead1.getEmpName() << endl;
- cout << "EmpNumber:" << lead1.getEmpNumber() << endl;
- cout << "HireDate:" << lead1.getHireDate() << endl;
- cout << "Shift:" << lead1.getShift() << endl;
- cout << "Hourly Pay:" << lead1.getHourlyPay() << endl;
- cout << "Monthly Bonus:" << lead1.getMonthlyBonus() << endl;
- cout << "Required TrainingHours:"
- << lead1.getTRequiredHours() << endl;
- cout << "Attended Training Hours:"
- << lead1.getTAttendHours() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement