-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathUapCse.java
61 lines (60 loc) · 1.89 KB
/
UapCse.java
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.util.ArrayList;
public class UapCse {
public String name;
ArrayList<Employee>employees = new ArrayList<>();
public UapCse(String name){
this.name = name;
System.out.println("*****Welcome to the dept. of CSE*****");
}
private void addNewEmployee(Employee e){
employees.add(e);
System.out.println("New employee has been employed!!");
}
public void addNewEmployee(String n,String i,String d,double s){
SalariedEmployee e = new SalariedEmployee(n,i,d,s);
addNewEmployee(e);
}
public void addNewEmployee(String n,String i,String d,double hr,int hw){
HourlyEmployee e = new HourlyEmployee(n,i,d,hr,hw);
addNewEmployee(e);
}
public void addNewEmployee(String n,String i,String d,double p,double s){
CommissionEmployee e = new CommissionEmployee(n,i,d,p,s);
addNewEmployee(e);
}
public Employee findEmployee(String id){
for(Employee x : employees){
if(x.getId().equals(id))
return x;
}
System.out.println("Employee not found!");
return null;
}
public void increaseSalary(String id,double amt) throws InvalidSalaryException{
Employee x = findEmployee(id);
if(x!=null){
x.increaseSalary(amt);
}
else
System.out.println("Employee not found!");
}
public double getSalary(String id){
Employee x = findEmployee(id);
if(x!=null){
return x.getSalary();
}
System.out.println("Employee not found!");
return -1;
}
public void display(String id){
Employee x = findEmployee(id);
if(x!=null){
x.display();
}
}
public void display(){
for(Employee x : employees){
x.display();
}
}
}