-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathIntern.java
More file actions
35 lines (24 loc) · 931 Bytes
/
Intern.java
File metadata and controls
35 lines (24 loc) · 931 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
33
34
35
import java.io.FileWriter;
import java.io.IOException;
public class Intern extends Employee {
// need advice --> idk if it is okay to create FileWriter outside the method(for
// creating object only once)
private static final double maxSalary = 20000;
private Intern(String name, String email, int age, double salary) {
super(name, email, age, salary);
try {
FileWriter fW = new FileWriter("employees.txt", true);
fW.write(name +" "+ email +" "+age +" "+ salary +"\n");
fW.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static Intern newIntern(String name, String email, int age, double salary) {
if (salary > maxSalary) {
throw new IllegalArgumentException("maas 20k ustu intern yaratmaq olmaz");
}
else{return new Intern(name, email, age, salary);
}
}
}