-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmployeeExample.java
73 lines (70 loc) · 2.14 KB
/
EmployeeExample.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
62
63
64
65
66
67
68
69
70
71
72
73
class Employee{
String name;
String address;
int age;
long phoneNo;
long salary;
Employee(String name, int age, long phoneNo, long salary, String address){
this.name=name;
this.age=age;
this.phoneNo=phoneNo;
this.salary=salary;
this.address=address;
}
public void PrintSalary(){
System.out.println("Salary:" +salary);
}
public void PrintDetails(){
System.out.println("Name:" +name);
System.out.println("Age:" +age);
System.out.println("Phone Number:" +phoneNo);
System.out.println("Address:" +address);
System.out.println("Salary:" +salary +"$");
}
}
class Officer extends Employee{
String Specialisation;
public Officer(String name, int age, long phoneNo, long salary, String address, String Specialisation){
super(name, age, phoneNo, salary, address);
this.Specialisation=Specialisation;
}
void PrintDetails(String occupation){
if(occupation=="Officer"){
System.out.println("Name:" +name);
System.out.println("Age:" +age);
System.out.println("Phone Number:" +phoneNo);
System.out.println("Address:" +address);
System.out.println("Salary:" +salary+"$");
System.out.println("Specialisation:"+Specialisation);
}
}
}
class Manager extends Employee{
String Department;
public Manager(String name, int age, long phoneNo, long salary, String address, String Department){
super(name, age, phoneNo, salary, address);
this.Department=Department;
}
public void PrintDetails(String occupation){
if(occupation=="Manager"){
System.out.println("Name:" +name);
System.out.println("Age:" +age);
System.out.println("Phone Number:" +phoneNo);
System.out.println("Address:" +address);
System.out.println("Salary:" +salary+"$");
System.out.println("Department:" +Department);
}
}
}
class EmployeeExample{
public static void main(String args[])
{
Employee Employee1=new Employee("Harry", 32, 9898989, 50000, "Florida");
Officer Employee2=new Officer("John", 39, 7007007, 500000, "Los Angles", "Mercenary");
Manager Employee3=new Manager("Winston", 60, 9876543, 5000000, "New York", "Continental");
Employee2.PrintSalary();
Employee1.PrintDetails();
Employee2.PrintDetails("Officer");
Employee3.PrintDetails("Manager");
}
}