Question

In: Computer Science

You will take the example from the Code Along where we wrote the Employee and ProductionWorker...

You will take the example from the Code Along where we wrote the Employee and ProductionWorker class and modify.

In a particular factory, a team leader is an hourly paid production worker who leads a small team. In addition to hourly pay, team leaders earn a fixed monthly bonus, Team leaders are required to attend a minimum number of hours of training per year. Design a TeamLeader class that extends the ProductionWorker class we designed together. The TeamLeader class should have member variables for the monthly bonus amount, the required number of training hours, and the number of training hours that the team leader has attended. Write one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate the class by writing a program that uses a TeamLeader object. Please type whole Program. Make sure you type which is main which is class.h. This is CPP

Here is Employee.h

#pragma once
#include<iostream>
#include<string>
using namespace std;

class Employee
{
private:
   string name;
   string number;
   string hireDate;

public:
   Employee()
   {
       name = ""; number = ""; hireDate = "";

   }
   Employee(string aName, string aNumber, string aDate)
   {
       name = aName; number = aNumber; hireDate = aDate;

   }

   void setName(string n)
   {
       name = n;

   }
   void setNumber(string num)
   {
       number = num;
   }
   void setHireDate(string date)
   {
       hireDate = date;
   }
   string getName() const
   {
       return name;
   }

};

Here is ProducitonWorker.h

#pragma once
#include"Employee.h"
#include <string>
using namespace std;

class ProductionWorker : public Employee
{
private:
   int shift;
   double payRate;

public:
   ProductionWorker() :Employee()
   {
       shift = 0; payRate = 0.0;
   }
   ProductionWorker(string aName, string aNumber, string aDate, int aShift, double aPayRate) :Employee(aName, aNumber, aDate)
   {
       shift = aShift; payRate = aPayRate;
   }
   void setShift(int s)
   {
       shift = s;
   }
   void setPayRate(double r)
   {
       payRate = r;
   }
   int getShiftNumber() const
   {
       return shift;
   }
   string getShiftName() const
   {
       if (shift == 1)
           return "Day";
       else if (shift == 2)
           return "Night";
       else
           return "Invalid";
   }
   double getPayRate() const
   {
       return payRate;

   }
};

Solutions

Expert Solution

In case of any query do comment. Please rate answer as well. Thanks

Code:

=====main.cpp=======

#include "TeamLeader.h"

int main()
{
    //Create an object of TeamLeader
    TeamLeader tl("ALex", "123", "23NOV2011", 2, 40,1000, 35,40);
    
    //display object properties
    cout << "Name: " << tl.getName() << endl;
    cout << "Shift: " << tl.getShiftNumber() << endl;
    cout << "Payrate: " << tl.getPayRate()<< endl;
    cout << "MonthlyBonus: " << tl.getMonthlyBonus()<< endl;
    cout << "RequiredTrainingHours: " << tl.getRequiredTrainingHours()<< endl;
    cout << "AttendedTrainingHours: " << tl.getAttendedTrainingHours()<< endl;
    cout << "Name: " << tl.getName()<< endl;

    return 0;
}

=============TeamLeader.h=========

#pragma once
#include"ProducitonWorker.h"
#include <string>
using namespace std;

class TeamLeader: public ProductionWorker
{
    private:
        double monthlyBonus;
        int requiredTrainingHours;
        int attendedTrainingHours;
        
    public:
    //constructors
        TeamLeader(): ProductionWorker()
       {
           monthlyBonus=0.0;
           requiredTrainingHours=0;
           attendedTrainingHours=0;
       }
       TeamLeader(string aName, string aNumber, string aDate, int aShift, double aPayRate, double aMonthlyBonus, int aRequiredTrainingHours, int aAttendedTrainingHours): 
            ProductionWorker(aName, aNumber, aDate, aShift, aPayRate)
       {
           monthlyBonus = aMonthlyBonus; requiredTrainingHours = aRequiredTrainingHours;; attendedTrainingHours = aAttendedTrainingHours;
       }
   
    //mutators
    void setMonthlyBonus(double b)
   {
       monthlyBonus = b;
       
   }
   
    void setRequiredTrainingHours(int rth)
   {
       requiredTrainingHours = rth;
       
   }
   
    void setAttendedTrainingHours(int ath)
   {
       attendedTrainingHours = ath;
       
   }
   
   //accessors
   double getMonthlyBonus() const
   {
       return monthlyBonus;

   }
   
    int getRequiredTrainingHours() const
   {
       return requiredTrainingHours;
       
   }
   
    int getAttendedTrainingHours() const
   {
       return attendedTrainingHours ;
       
   }
    
};

===========Screen shot of the code===========

output:


Related Solutions

Write code in java using the LinkedList connecting two different classes. For example, Employee and EmployeeList...
Write code in java using the LinkedList connecting two different classes. For example, Employee and EmployeeList are two different classes that are used to create the assignment.
Where did the idea of employee health insurance come from? Do you think the U.S. would...
Where did the idea of employee health insurance come from? Do you think the U.S. would take the same approach to health insurance if this concept was being proposed today?
An employee has come to you with a request to take on a part-time job. The...
An employee has come to you with a request to take on a part-time job. The employee would be working for Price Waterhouse as a contract employee during tax season. The employee has assured you that she will not work more than 20 hours a week, primarily on weekends. Price-Waterhouse is one of the five accounting firms that has put a bid in to do the auditing for G-BioSport. Possible Solutions: Allow the accountant to work as long as a...
An employee has come to you with a request to take on a part-time job. The...
An employee has come to you with a request to take on a part-time job. The employee would be working for Price Waterhouse as a contract employee during tax season. The employee has assured you that she will not work more than 20 hours a week, primarily on weekends. Price-Waterhouse is one of the five accounting firms that has put a bid in to do the auditing for G-BioSport. Possible Solutions: Allow the accountant to work as long as a...
An employee has come to you with a request to take on a part-time job. The...
An employee has come to you with a request to take on a part-time job. The employee would be working for Price Waterhouse as a contract employee during tax season. The employee has assured you that she will not work more than 20 hours a week, primarily on weekends. Price-Waterhouse is one of the five accounting firms that has put a bid in to do the auditing for G-BioSport. Be Reasonable: Explore the Options 1. Basic Liberties Choose three options...
* Make sure you turn in your code (take a screen shot of your code in...
* Make sure you turn in your code (take a screen shot of your code in R)and answers. Conduct the hypothesis and solve questions by using R. 2) A random sample of 12 graduates of a secretarial school averaged 73.2 words per minute with a standard deviation of 7.9 words per minute on a typing test. What can we conclude, at the .05 level, regarding the claim that secretaries at this school average less than 75 words per minute on...
THE CODE IN THIS QUESTION IS STORED IN THE MEMORY FROM ADDRESS 0X1FFF000. SO TAKE THIS...
THE CODE IN THIS QUESTION IS STORED IN THE MEMORY FROM ADDRESS 0X1FFF000. SO TAKE THIS INTO CONSIDERATION. 1.     In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x1fff0000. Loop: sw $t1, 4($s0)        addi $t1, $t1, -1    sll $t1, $t1, 2        bne $t1, $s5, Exit    addi $s0, $s0, 4          j Loop Exit: … ********************************THE FOLLOWING...
Provide an example of a firm where having a take-over defence would work in the best...
Provide an example of a firm where having a take-over defence would work in the best interest of both shareholders and management. Explain.
In Chapter employee benefit we explored employee benefits. If you were starting a small business of...
In Chapter employee benefit we explored employee benefits. If you were starting a small business of say 250 employees what type of benefits would you have to provide? Which would you offer as supplemental? Explain why you included each benefit.
Produce an example from your life or career of a situation where you faced a strategic...
Produce an example from your life or career of a situation where you faced a strategic decision along the lines of a game theoretic environment. If you are not comfortable doing that then please construct a reasonable example situation. You must have 2 players in the game you and another entity. The actions of neither player are known with certainty and there is no way to put a probability statement on either strategy. Limit your example to 2 players and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT