-
Notifications
You must be signed in to change notification settings - Fork 0
/
PersonTest.java
40 lines (31 loc) · 1.33 KB
/
PersonTest.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
public class PersonTest
{
public static void main(String[] args) {
// Creating objects of Person class
Teacher person1 = new Teacher("Alice", 25, "math");
Teacher person2 = new Teacher("Bob", 30, "poetry");
Teacher person3 = new Teacher("Veronica", 30, "logic");
// Accessing and printing information using getter methods
System.out.println("Teacher 1:");
System.out.println("Name: " + person1.getName());
System.out.println("Age: " + person1.getAge());
System.out.println("ID: " + person1.getTeacherID());
System.out.println();
System.out.println("Teacher 2:");
System.out.println("Name: " + person2.getName());
System.out.println("Age: " + person2.getAge());
System.out.println("ID: " + person2.getTeacherID());
System.out.println();
System.out.println("Teacher 1:");
System.out.println("Name: " + person3.getName());
System.out.println("Age: " + person3.getAge());
System.out.println("ID: " + person3.getTeacherID());
System.out.println();
// Changing information using setter methods
person1.setName("Charlie");
person1.setAge(35);
// Printing updated information
System.out.println("Updated Person 1:");
person1.printInfo();
}
}