-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathIntern.java
More file actions
29 lines (24 loc) · 809 Bytes
/
Intern.java
File metadata and controls
29 lines (24 loc) · 809 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
package Task03;
/*
2. Create an Intern class that extends from Employee. All the Interns have a salary limit of 20000 (constant). You must validate if an intern is created (or salary updated) with a bigger salary than the max. The max value is set.
*/
public class Intern extends Employee {
private static final double salaryLimit = 20000;
/**
* Caps the salary to salaryLimit if a higher value is provided.
*/
@Override
public void setSalary(double salary) {
if (salary > salaryLimit) {
salary = salaryLimit;
}
super.setSalary(salary);
}
/**
* Ignores the provided designation and forces it to "Intern".
*/
@Override
public void setDesignation(String designation) {
super.setDesignation("Intern");
}
}