Assignment
2:
The aim of this assignment is to demonstrate the use of class, subclass,
inheritance, polymorphism and the reusability of classes.
Problem description
Consider a company that has many employees. The job titles of employees are
Worker, Manager and Director. At the end of the year the company declares its
best worker, manager and director based on some performance criteria. You have
to write a program that takes information about the employees from the keyboard,
finds the best worker, manager and director, and print their names on screen.
Assumption: mangers and directors are basically the same. Directors
are involved in large projects and their performance is calculated differently
from managers.
Use the following hints:
- All the workers, managers and directors are the employees
of the company. They must have some common basic information, e.g., employee
id, name, age, tax file number, job title etc. regardless of their job
positions. So Employee
can be a class and it can be extended to write Worker, Manager and Director
classes.
- Worker
class can be subclass of Employee class. See Worker class for
calculating performance index of each worker.
- Similarly Manager
class can be a subclass of Employee class.
- Crate Director
class. The only difference between manager and director is the way their
performance is calculated. So Director can be a subclass of Manager.
- Create a class Award
that will print the best worker, manager and director. You should use the
concept of polymorphism here. The output of the program should be something
like this.