-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathEmployee.java
More file actions
74 lines (65 loc) · 1.57 KB
/
Employee.java
File metadata and controls
74 lines (65 loc) · 1.57 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
package com.rt.cloning;
//Employee Class Changes done from diff acc now
public class Employee implements Cloneable{
int eid;
public Employee(int eid, String ename) {
super();
this.eid = eid;//
this.ename = ename;
}
public int getEid() {
return eid;
}
public void setEid(int eid) {
this.eid = eid;
}
public String getEname() {
return ename;
}
public void setEname(String ename) {
this.ename = ename;
}
public Department getDep() {
return dep;
}
public void setDep(Department dep) {
this.dep = dep;
}
String ename;
Department dep;
public Employee(int eid, String ename, Department dep) {
super();
this.eid = eid;
this.ename = ename;
this.dep = dep;
}
public Employee(Employee e1) {
this.eid=e1.eid;
this.ename=e1.ename;
this.dep=new Department(e1.dep);
// TODO Auto-generated constructor stub
}
@Override
public String toString() {
// TODO Auto-generated method stub
return "Employee id: "+eid+" Employee Name: "+ename+" Dep Name:"+dep.getDname()+" Dep Id:"+dep.getDid();
}
@Override
protected Employee clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
Employee temp=(Employee)super.clone();
temp.setDep(this.getDep().clone());
// temp.dep=this.dep.clone();
return temp;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
Employee temp=(Employee) obj;
if(this.getEid()==temp.getEid())
return true;
else
return false;
// return super.equals(obj);
}
}