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

In this homework, we will write the code that will take an expression (input) from the...
In this homework, we will write the code that will take an expression (input) from the user in infix notation and convert that to corresponding postfix notation and evaluate its value. Task 0: Use the starter code to start. All the needed functions and their functionalities are given in the starter code. Task 1: Complete the startercodeinfixtopostfix.c file Task 2: Complete the startercodeevaluatepostfix.c file Sample Input/Output: (Infix to postfix) Input: (A + B)*C-D*E Output: A B + C * D...
I wrote this code and it produces a typeError, so please can you fix it? import...
I wrote this code and it produces a typeError, so please can you fix it? import random def first_to_a_word(): print("###### First to a Word ######") print("Instructions:") print("You will take turns choosing letters one at a time until a word is formed.") print("After each letter is chosen you will have a chance to confirm whether or not a word has been formed.") print("When a word is formed, the player who played the last letter wins!") print("One of you has been chosen...
In regard to society, where we have come from and where we are going? If any...
In regard to society, where we have come from and where we are going? If any person claims to be a member or participant of a society, that person must also observe and analyze what he or she is a part of, and hopefully aim to improve it. Please define (explain in detail) the qualities and characteristics needed for a successful society. Society is both a concept and a living, breathing, changing entity. Explain your subjective view of what makes...
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...
Answer in Python: show all code 3) Modify your code to take as input from the...
Answer in Python: show all code 3) Modify your code to take as input from the user the starting balance, the starting and ending interest rates, and the number of years the money is in the account. In addition, change your code (from problem 2) so that the program only prints out the balance at the end of the last year the money is in the account. (That is, don’t print out the balance during the intervening years.) Sample Interaction:...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT