/EmployeePayroll

Payroll system for company's clerks and managers

Primary LanguageJava

EmployeePayroll

Payroll system for company's clerks and managers

You are required implement a solution for the following requirements: Class Employee The main class is Employee. An employee has the following instance variables: age: an integer birthDay: a number between 1 and lengthOfYear salary: an integer vacationDays: an integer giving the number of available vacation days for the remainder of the year On employees the following methods work: Employee: sets all parameters increaseSalary: multiplies the salary by (1 + salaryIncrease) takeVacationDay: returns true if vacationDays > 0 and decreases vacationDays by 1, returns false otherwise addVacationDays: replaces vacationDays by vacationDays / 2 + days checkBirthday: checks whether currentDay, which is passed as a parameter equals birthDay, and if yes returns true otherwise false. age is increased by one if the employee has birthday checkRetirement: returns true if age exceeds 65, otherwise false paySalary(int i): prints that company pays salary to employee i toString: lists all variables on a single line

Class Clerk Clerk is a derived class from Employee. A clerk has one extra instance variable: illDays: an integer counting the number of days the person was ill during the last calendar year On clerks the following additional methods work: resetIllDays: sets illDays = 0 addIllDays: adds one to illDays getIllDays: returns the value of illDays toString: adds the additional variable to the variables of Employee Class Director Director is a derived class from Employee. A director has one extra instance variable: gratification: a double giving the fraction of the profit this director gets at the end of the year On director the following additional methods work: payGratification(int i): prints how much gratification the company pays to employee i toString: adds the additional variable to the variables of Employee Class Company Then there is the class Company. It has the following instance variables: lengthOfYear: an integer currentDay: an integer numberOfEmployees: an integer profit: an integer employee: an array of Employee Methods working on companies are: Company(int maxSize, int l): creates a company with 0 employees and an array of length maxSize and lenghtOfYear = l

employClerk(int i): creates a new clerk with all its variables as employee[i]. Variables are chosen randomly in a reasonable range. Clerks get 5 vacation days. addClerk() adds a clerk at the end of the employee array employDirector(int i): creates a new director with all its variables as employee[i]. Variables are chosen randomly in a reasonable range. Directors get 8 vacation days. addClerk() adds a director at the end of the employee array dayStep: increases currentDay by 1. Tests whether currentDay % (lengthOfYear / 4) = 0. if yes, salaries are paid out. Tests for the end of the year. if yes, gratifications are paid out and illDays are reset. Then it sets currentDay = 0. Tests for birthdays. If yes, the salary is increased. Then it also tests whether it is time to retire. Then, for all employees, it is randomly chosen whether to be ill, take free or work. If clerks are ill too often they are fired. If an employee wants free but vacationDay == 0, he must work. Class CompanyTest On top of all, there is a class CompanyTest. It contains main. It creates a company with 3 directors and 17 clerks. Then it performs 100 daySteps with lengthOfYear = 40. Note: Random numbers can be generated by methods from the class Random in java.util. It is You may use "instanceof", which allows to test to which class an object belongs.