Code Monkey home page Code Monkey logo

inheritancepractice's Introduction

InheritancePractice

Designed and implemented classes of an inheritance hierarchy for Employee, Boss, HourlyWorker, and CommissionWorker as specified here:

(1) Employee is a base class containing the interface to the hierarchy (note: this could be designed as an abstract class.) It has the following private data members: first name, last name, birthday, and department code, where the department code is one of the Accounting, Purchasing, Marketing, Manufacturing, and Management departments. Use string objects for the names. The class has constructor(s), a destructor and other necessary member functions. It has two virtual functions, one is earning function that calculates and returns the employee’s earning, and another print function that employee’s information including his/her earnings. You may define a friend function that overloads << for displaying the Employee object information (i.e. the overloading << function will call the virtual print function.)

(2) Boss class inherits from the Employee class with additional information of monthly salary. It defines its own earning and print functions.

(3) Hourlyworker class inherits from the Employee class with additional information of hourly rate and hours worked in this month. It defines its own earning and print functions.

(4) CommissionWorker class inherits from the Employee class with additional information of base salary, items sold for the month, and commission per each item. It defines its own earning and print functions.

Also, design and implement a Date class with the following requirements: (1) a default constructor that sets the Date object to the first day of year 2000, and (2) a constructor with month, day, and year either passed as parameter or inputted by the user with all information verified – month should be in the range from 1 to 12, year should be greater than 1900, and day should be in the range from 1 to 31 depending on the corresponding month (note: ignore the leap year.) If parameter values are out of range, set the date to first day of year 2000. Other member functions include getMonth, getDay, getYear, etc. Also, use a friend function to overload an operator function << for output of Date object.

Main function: (1) user enters today’s day; (2) it calculates the payroll for each employee and add $500.00 bonus to the person's payroll amount if this is the month in which the employee's birthday occurs; and (3) prints out the payroll for each employee of this month. Run the main program and test your member functions thoroughly.

inheritancepractice's People

Contributors

madhavc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.