The director of a chemical products company wants to manage salaries and
employee bonuses through a Java program.
An employee is characterized by their last name, first name, age, and date of entry.
service in the company.
In a file [Link], code an abstract class Employee equipped with the
necessary attributes, for an abstract method calculateSalary
(this calculation will indeed depend on the type of employee) and a method getNom
returning a string obtained by concatenating the string
"The employee" with the first name and last name.
Also endow your class with a constructor that takes as parameter the set of
necessary attributes.
Salary calculation
The calculation of the monthly salary depends on the type of employee. Different types are distinguished.
of the following employees:
1- Those assigned to Sales. Their monthly salary is 20% of the turnover.
that they carry out monthly, plus 400 Francs.
2- Those assigned to the Representation. Their monthly salary is also 20% of the
monthly revenue they generate, over 800 Francs.
3- Those assigned to Production. Their salary is worth the number of units produced.
monthly multiplied by 5.
4- Those assigned to Handling. Their salary corresponds to their number of hours of
monthly work multiplied by 65 francs.
Code in your file [Link] a class hierarchy for employees
while respecting the following conditions:
1- The superclass of the hierarchy must be the Employee class.
2- The new classes must contain their specific attributes.
as well as the appropriate coding of the methods calculateSalary and getName,
by changing the word "employee" to the corresponding category.
3- Chaque sous classe est dotée de constructeur prenant en argument l’ensemble des
necessary attributes.
4- Do not hesitate to introduce intermediate classes to minimize the ...
attribute and method redundancies in subclasses
At-risk employees
Some employees in the production and handling sectors are called to manufacture
and handle hazardous products.
After several union negotiations, the latter manage to obtain a
monthly risk premium.
Complete your [Link] program by introducing two new subclasses.
of employees. These subclasses will refer to employees in the production sectors.
and handling working with hazardous materials.
Also add an interface for at-risk employees to your program.
allowing them to associate a fixed monthly bonus of 200.-.
Collection of employees
Satisfied with the proposed hierarchy, our director now wishes to
to use it to display the salary of all its employees as well as the salary
average.
Add a Personnel class containing a 'collection' of employees. It will be
from a polymorphic collection of Employee - look at the course if you do not see
what it is about.
Then define the following methods in the Personnel class:
void addEmployee(Employee) that adds an employee to the collection.
void calculateSalaries() which displays the salary of each employee of the
collection.
double averageSalary() that displays the average salary of the employees in the collection.
Test your program with the following main:
class Salaries {
public static void main(String[] args) {
Personnel p = new Personnel();
[Link](new Vendeur("Pierre", "Business", 45, "1995", 30000));
[Link](new Representative("Léon", "Vendtout", 25, "2001", 20000));
[Link](new Technician("Yves", "Worker", 28, "1998", 1000));
[Link](new Manutentionnaire("Jeanne", "Stocketout", 32, "1998",
45));
addEmployee(new TechnARisque("Jean", "Flippe", 28, "2000", 1000));
[Link](new RiskyHandler("Al", "Abordage", 30, "2001", 45));
[Link]();
The average salary in the company is
averageSalary() + " francs.";
}
}
You should get something like:
The seller Pierre Business earns 6400.0 francs.
Representative Léon Vendtout earns 4800.0 francs.
Technician Yves Bosseur earns 5000.0 francs.
The driver Jeanne Stocketout earns 2925.0 francs.
Technician Jean Flippe earns 5200.0 francs.
The handling. At the boarding wins 3125.0 francs.
The average salary in the company is 4575.0 francs.
[Link]