Repository navigation
Expand file tree
/
Copy pathPersonEmp.java
More file actions
109 lines (82 loc) · 2.21 KB
/
Copy pathPersonEmp.java
File metadata and controls
109 lines (82 loc) · 2.21 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
class Person
{
String name;
void setName(String name)
{
this.name = name;
}
String getName()
{
return this.name;
}
void display()
{
System.out.println("Personname="+name);
}
}
class Employee extends Person
{
double salary;
int startyear;
String UAN;
Employee(String name, double salary, int startyear, String UAN)
{
this.setName(name);
this.salary = salary;
this.startyear = startyear;
this.UAN = UAN;
System.out.println("Employee: " + name +"Salary: " + salary+"StartYear: " + startyear+"UAN: " + UAN);
}
public double getSalary() {
return salary;
}
String getName()
{return this.name;}
public void setSalary(double salary) {
this.salary = salary;
}
public int getstartyear() {
return startyear;
}
public void setstartyear(int year){
this.startyear = year;
}
public String getUAN() {
return UAN;
}
public void setUAN(String UAN) {
this.UAN = UAN;
}
void display()
{
System.out.println("Employee: " + name +"Salary: " + salary+"StartYear: " + startyear+"UAN: " + UAN);
}
}
public class PersonEmp
{
public static void main(String[] args) throws Exception
{
Person person1 = new Person();
person1.setName("krishna");
Person person2 = new Person();
Employee employee1= new Employee("krishna",3000.235,2002,"18691A2534");
Employee employee2 = new Employee("vamsi",4000.24,2000,"18691A2534");
person2.setName("KISHAN");
person2.display();
employee1.display();
employee2.display();
// person and employee details
if(person1.getName().equals(employee1.getName()))
{
System.out.println("Person object is the same as any of the Employee ");
}
if(person2.getName().equals(employee1.getName()))
{
System.out.println("Person object is the same as any of the Employee ");
}
if(employee1.getUAN().equals(employee2.getUAN()))
{
System.out.println("BOTH employees are same");
}
}
}