Object Oriented Programming
Lab Task
Submission Dead line 09-05-2020 till 12:00 AM
Points 30
Objective:
For better understanding of Multiple and Multi-level Inheritance.
Question 1:
Design a class named Employee. The class should keep the following information in member variables:
Employee name
Employee number
Hire date
Write one or more constructors and the appropriate accessor and mutator functions for the class. Next, write
a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class
should have member variables to hold the following information:
Shift (an integer)
Hourly pay rate (a double)
The workday is divided into two shifts: day and night. The shift variable will hold an integer value
representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write
one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate the
classes by writing a program that uses a ProductionWorker object.
Output:
Please Enter Employee Number to see the
details: 23
Name : Ali
Hire Date: 23/03/1996
Shift: Night
Hourly Pay Rate: $30
Question 2:
Imagine a publishing company that markets both book and audiocassette versions of its works.
Create a class publication that stores the title (a string) and price (type float) of a publication. From
this class derive two classes: book, which adds a page count (type int), and tape, which adds a
playing time in minutes (type float). Each of these three classes should have a getdata() function
to get its data from the user at the keyboard, and a putdata() function to display its data.
Write a main() program to test the book and tape classes by creating instances of them, asking the
user to fill in data with getdata(), and then displaying the data with putdata().
Question 3:
We have a database of employees of a Mining company. We’ve simplified the situation so that only three
kinds of employees are represented. Managers manage, scientists perform research to develop better
methods, and laborers operate the dangerous mining task.
The database stores a name and an employee identification number for all employees, no matter
what their category. However, for managers, it also stores their titles and golf club dues. For scientists, it
stores the number of scholarly articles they have published. Laborers need no additional data beyond their
names and numbers.
Our program starts with a base class employee. This class handles the employee’s last name and employee
number. From this class three other classes are derived: manager, scientist, and laborer. The manager and
scientist classes contain additional information about these categories of employee, and member functions
to handle this information. Write a program that demonstrate all these classes and display details of
employee as you can see in first program output.
Happy Coding