forked from ironhack-labs/lab-java-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntern.java
More file actions
22 lines (18 loc) · 706 Bytes
/
Intern.java
File metadata and controls
22 lines (18 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Intern extends Employee {
public static final double MAX_SALARY = 20000;
public Intern(int employeeId, String name, String lastName, int age, String department, String position, double salary) {
super(employeeId, name, lastName, age, department, position, 0);
setSalary(salary);
}
@Override
public void setSalary(double salary) {
if (salary > MAX_SALARY) {
throw new IllegalArgumentException("Intern salary cannot exceed " + MAX_SALARY + ".");
}
super.setSalary(salary);
}
@Override
public String toString() {
return super.toString() + "\nRole : Intern\nSalary cap : " + MAX_SALARY;
}
}