-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployeeList.java
More file actions
92 lines (91 loc) · 1.76 KB
/
EmployeeList.java
File metadata and controls
92 lines (91 loc) · 1.76 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.util.ArrayList;
public class EmployeeList
{
private ArrayList<Employee> empList;
EmployeeList()
{
empList=new ArrayList<>();
}
int search(int empcode)
{
for(int i=0;i<empList.size();i++)
{
if(empList.get(i).getCode()==empcode)
{
return i;
}
}
return -1;
}
boolean canAddEmployee(int empcode)
{
int k=search(empcode);
if(k!=-1)
{
return false;
}
else{
return true;
}
}
String addEmployee(Employee e)
{
empList.add(e);
return "Employee added successfully";
}
Employee displayEmp(int empcode)
{
int k=search(empcode);
if(k==-1)
{
return null;
}
else{
return empList.get(k);
}
}
}
class Employee
{
private int code;
private String name;
private int depcode;
private double basic;
private char grade;
public Employee(int c,String n,int dcode,double b,char g)
{
code=c;
name=n;
depcode=dcode;
basic=b;
grade=g;
}
public int getCode()
{
return code;
}
public int getDepCode()
{
return depcode;
}
public double getBasic()
{
return basic;
}
public char getGrade()
{
return grade;
}
public String getName()
{
return name;
}
public String toString()
{
return "Name:"+name+'\n'
+"Employee Code:"+code+'\n'
+"Department Code:"+code+'\n'
+"Basic salary:"+basic+'\n'
+"Grade:"+grade+'\n';
}
}