Tuesday, May 15, 2007

assignment 1 - Employee hierarchy test application - polymorphism

// PayrollSystemTest.cs
// Employee hierarchy test application.
// this test will create each type of employees to the system
// declare an employee matrix with size of 4
// assign each element to one of the employee and
// generically process each element in array employees ( polymorphism )


the program will process using polymorphism technic by creating an array of their base class,
and assign each element to the specific object.

methodology:
I added 2 private variable in Employee class to store date class information about each employee's birthday and hire date
- private Date birthDate;
- private Date hireDate;
and 1 protected decimal bonus. I am using protected variable in order to let derived classes use bonus variable to add bonus to the earning.

thus, the constructor of base class employee need to add 2 more arguement
by adding dateOfBirth and dateOfHire varialbes of Date type to function declaration.
This also influences derieved class constructors that used base class constructor which their constructor needs to add
": base( first, last, ssn, dateOfBirth, dateOfHire )"


adding bonus feature:
because we need to check if an employee birthday month,
we need to create a public assessor of private Date birthDate. The bonus will be added if there is a match and
this feature will be handled in earning method in each type of employees.

advantance test program:
this program is using PayrollManager class to manage adding, display monthly report, and list of employees. Some employees
from PayrollSystemTest.cs is initialize in the class constructor.
because this is a mini program. this program will not tolarate some invalid input, such as: inputing empty character in menu.
Please follow format example if it is available.


download sample code here:
assignment1.zip

No comments: