0% found this document useful (0 votes)
6 views4 pages

ASGN202 Docx

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

ASGN202 Docx

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ID: ASGN202:

class Person {
private String name;
private int age;
private String gender;
public Person(String name, int age, String gender) {
this.name = name;
this.age = age;
this.gender = gender;
}
public String getName() {
return name;
}

public void setName(String name) {


this.name = name;
}
public int getAge() {
return age;
}

public void setAge(int age) {


this.age = age;
}
public String getGender() {
return gender;
}

public void setGender(String gender) {


this.gender = gender;
}
public void displayPersonInfo() {
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Gender: " + gender);
}
}
private String specialization;
private int experience;
public Doctor(String name, int age, String gender, String specialization, int experience) {
super(name, age, gender);
this.specialization = specialization;
this.experience = experience;
}
public String getSpecialization() {
return specialization;
}

public void setSpecialization(String specialization) {


this.specialization = specialization;
}
public int getExperience() {
return experience;
}

public void setExperience(int experience) {


this.experience = experience;
}

public void displayPersonInfo() {


super.displayPersonInfo();
System.out.println("Specialization: " + specialization);
System.out.println("Experience: " + experience + " years");
}
}
class Patient extends Person {
private String illness;
private String admissionDate;
public Patient(String name, int age, String gender, String illness, String admissionDate) {
super(name, age, gender);
this.illness = illness;
this.admissionDate = admissionDate;
}

public String getIllness() {


return illness;
}

public void setIllness(String illness) {


this.illness = illness;
}
public String getAdmissionDate() {
return admissionDate;
}

public void setAdmissionDate(String admissionDate) {


this.admissionDate = admissionDate;
}
public void displayPersonInfo() {
super.displayPersonInfo();
System.out.println("Illness: " + illness);
System.out.println("Admission Date: " + admissionDate);
}
}
public class HealthcareTest {
public static void main(String[] args) {
Doctor doctor = new Doctor("Dr. John Smith", 45, "Male", "Cardiology", 20);
Patient patient = new Patient("Emily Clark", 30, "Female", "Pneumonia", "2024-10-
18");
System.out.println("Doctor Information:");
doctor.displayPersonInfo();
System.out.println();
System.out.println("Patient Information:");
patient.displayPersonInfo();
}
}

OUTPUT:
Doctor Information:
Name: Dr. John Smith
Age: 45
Gender: Male
Specialization: Cardiology
Experience: 20 years

Patient Information:
Name: Emily Clark
Age: 30
Gender: Female
Illness: Pneumonia
Admission Date: 2024-10-18

You might also like