Question: Class Employee: Create a default class called Employee. An employee should include seven pieces of information as instance variables: 1 . name: the name of
Class Employee: Create a default class called Employee. An employee should include seven pieces of information as instance variables: name: the name of the employee id: an automatically generated string based on the year this employee was hired digits this employee was the th hire of the year digits For example, the th employee hired in should be hireYear: the year that the employee was hired. username: automatically generated string based on the following rules: a Get the first character of the employees first name b Get the employees entire last name c Join them together, and make each character lowercase d Add a number at the end based on how many existing usernames that are the same to make sure that all usernames are unique For example, if the employees name is David Smith and dsmithdsmith and dsmith already exist in the employees csv file, then Davids username should be dsmith rank: an integer value in the range of to to show this employees level within the company. The higher the number is the higher rank this employee holds. yearlyPayment: the employees income for this year. department: an object of the class Department. The department the employee works in Also, create a static variable, called numEmployee, to keep track of the number of employee objects that have been created. Employee records should be stored in a csv file called employees.csv in the following format: Each row represents an employees information with each column representing different attribute values of the employees, ie name, id username, rank, yearlyPayment, and departments departmentName in this order. Tasks: Add a constructor. The attributes, name, hireYear, yearlyPayment, and rank, must be specified. The attributes, id and username, are generated automatically. The initial value of the attribute, department, should be null. Add a get method for each attribute. Add a set method for the attribute, name. Add a promote method to promote an employees rank by one. This employees yearlyPayment should also be increased by dollars for each promotion. Add a saveRecord method to save this employees data to the employees.csv file when this employee object is created. Employee objects should be comparable based on their ranks. Implement the Comparable interface. You may add some private utility methods to facilitate your design. Create a class called HourlyPaidEmployee, which is a special type of employee. HourlyPaidEmployees do not get a flat salary. Instead, their annual salaries are calculated based on the number of hours they work. Therefore, this special class should have two additional attributes: hourlyPayRate: hourly pay rate of this employee hoursWorked: how many hours worked so far. Its initial value should be zero. Tasks: Add a constructor. Add a get method for hourlyPayRate and hoursWorked. Add a method called enterHoursint hours that can add the given hours to the existing number of hours worked so far. The yearlyPayment should be adjusted accordingly. Add a set method for hourlyPayRate that can update this employees hourlyPayRate. Create a class called Executive, which is another special type of employee. Executives have different promotions, which give them additional benefits: Tasks: Add a constructor. The promote method should also increase an executives rank by one. However, unlike a regular employee, an executives yearlyPayment should be increased by dollars for each promotion.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
