-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExp57.java
More file actions
114 lines (94 loc) · 3.49 KB
/
Exp57.java
File metadata and controls
114 lines (94 loc) · 3.49 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
110
111
112
113
114
class Person {
protected String name;
protected int age;
protected String address;
public Person(String name, int age, String address) {
this.name = name;
this.age = age;
this.address = address;
}
public void displayDetails() {
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Address: " + address);
}
}
class Staff extends Person {
protected String staffId;
protected String department;
public Staff(String name, int age, String address, String staffId, String department) {
super(name, age, address);
this.staffId = staffId;
this.department = department;
}
@Override
public void displayDetails() {
super.displayDetails();
System.out.println("Role: Staff");
System.out.println("Staff ID: " + staffId);
System.out.println("Department: " + department);
}
}
class Professor extends Staff {
private String specialization;
public Professor(String name, int age, String address, String staffId, String department, String specialization) {
super(name, age, address, staffId, department);
this.specialization = specialization;
}
public void conductLecture() {
System.out.println("Professor " + name + " is conducting a lecture on " + specialization);
}
@Override
public void displayDetails() {
super.displayDetails();
System.out.println("Role: Professor");
System.out.println("Specialization: " + specialization);
}
}
class Student extends Person {
protected String studentId;
protected String course;
public Student(String name, int age, String address, String studentId, String course) {
super(name, age, address);
this.studentId = studentId;
this.course = course;
}
@Override
public void displayDetails() {
super.displayDetails();
System.out.println("Role: Student");
System.out.println("Student ID: " + studentId);
System.out.println("Course: " + course);
}
}
class GraduateStudent extends Student {
private String researchTopic;
public GraduateStudent(String name, int age, String address, String studentId, String course, String researchTopic) {
super(name, age, address, studentId, course);
this.researchTopic = researchTopic;
}
public void submitThesis() {
System.out.println("Graduate student " + name + " is submitting thesis on " + researchTopic);
}
@Override
public void displayDetails() {
super.displayDetails();
System.out.println("Level: Graduate Student");
System.out.println("Research Topic: " + researchTopic);
}
}
public class Exp57 {
public static void main(String[] args) {
Professor professor = new Professor("Dr. Smith", 45, "123 Academic St", "P101", "Computer Science", "Artificial Intelligence");
GraduateStudent gradStudent = new GraduateStudent("John Doe", 25, "456 Scholar Ave", "G202", "Computer Science", "Machine Learning Applications");
System.out.println("----- University Personnel -----");
System.out.println("Professor:");
professor.displayDetails();
professor.conductLecture();
System.out.println("------------------------");
System.out.println("Graduate Student:");
gradStudent.displayDetails();
gradStudent.submitThesis();
System.out.println("------------------------");
}
}