Skip to content

Commit b0d0c0d

Browse files
committed
Create StaffMain.java
1 parent 77b6929 commit b0d0c0d

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

Staff_Details/StaffMain.java

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
Design a super class called Staff with details as StaffId, Name, Phone, Salary. Extend
3+
this class by writing three subclasses namely Teaching (domain, publications), Technical (skills), and Contract (period).
4+
Write a Java program to read and display at least 3 staff objects of all three categories.
5+
*/
6+
7+
package Staff_Details;
8+
9+
class Staff {
10+
protected int StaffId;
11+
protected String Name;
12+
protected String phone;
13+
protected int salary;
14+
15+
Staff(int sid, String n, String ph, int sal) {
16+
StaffId = sid;
17+
Name = n;
18+
phone = ph;
19+
salary = sal;
20+
}
21+
22+
void printStaff() {
23+
System.out.println("Staff ID:" + StaffId);
24+
System.out.println("Name:" + Name);
25+
System.out.println("Phone:" + phone);
26+
System.out.println("Salary:" + salary);
27+
}
28+
}
29+
30+
class Teaching extends Staff {
31+
private String Domain;
32+
private int Publication;
33+
34+
Teaching(int sid, String n, String ph, int sal, String dom, int pub) {
35+
super(sid, n, ph, sal);
36+
Domain = dom;
37+
Publication = pub;
38+
}
39+
40+
void printTeaching() {
41+
printStaff();
42+
System.out.println("Domain:" + Domain);
43+
System.out.println("Publication:" + Publication);
44+
}
45+
}
46+
47+
class Technical extends Staff {
48+
private String Skills;
49+
50+
Technical(int sid, String n, String ph, int sal, String skl) {
51+
super(sid, n, ph, sal);
52+
Skills = skl;
53+
}
54+
55+
void printTechnical() {
56+
printStaff();
57+
System.out.println("Skills:" + Skills);
58+
}
59+
}
60+
61+
class Contract extends Staff {
62+
private int Period;
63+
64+
Contract(int sid, String n, String ph, int sal, int prd) {
65+
super(sid, n, ph, sal);
66+
Period = prd;
67+
}
68+
69+
void printContract() {
70+
printStaff();
71+
System.out.println("Period:" + Period);
72+
}
73+
}
74+
75+
public class StaffMain {
76+
public static void main(String[] args) {
77+
Teaching th = new Teaching(3158, "Sour", "7204613547", 999999, "CS", 3);
78+
System.out.println("Teaching Staff Details");
79+
th.printTeaching();
80+
81+
Technical tcl = new Technical(3159, "Shan", "7989898494", 99999, "None");
82+
System.out.println("Technical Staff Details");
83+
tcl.printTechnical();
84+
85+
Contract ct = new Contract(3160, "Jason", "7743847348", 99999, 1);
86+
System.out.println("Contract Staff Details");
87+
ct.printContract();
88+
}
89+
}

0 commit comments

Comments
 (0)