-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathIntern.java
More file actions
32 lines (27 loc) · 859 Bytes
/
Intern.java
File metadata and controls
32 lines (27 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class Intern extends Employee {
// Constante para el límite de sueldo
private static final double MAX_SALARY_LIMIT = 20000.0;
// Constructor: Al llamar a super, ponemos "false" en el booleano de Full Time
public Intern(String id, String name, double salary) {
super(id, name, salary, false);
setSalary(salary);
}
// Sobrescribimos el Rol
@Override
public String getRole() {
return "INTERN STUDENT";
}
// Sobrescribimos el Setter
@Override
public void setSalary(double salary) {
validateAndSetSalary(salary);
}
// Método interno de validación
private void validateAndSetSalary(double salary) {
if (salary > MAX_SALARY_LIMIT) {
super.setSalary(MAX_SALARY_LIMIT);
} else {
super.setSalary(salary);
}
}
}