Hospital
Management System
Write a Java program
to implement inheritance and display user details based on the
inputs.
[Note: Strictly adhere to the object-oriented
specifications given as a part of the problem statement.
Follow the naming
conventions as mentioned. Create separate classes
in separate files.]
Data Type |
Variable |
String |
name |
String |
email |
String |
mobileNumber |
String |
address |
Create class User with the following private attributes/variables.
Include appropriate getters and setters.
Include parameterized constructor with parameters in the following order, public User(String name, String email, String mobileNumber,
String address)
In the User class include the following
method
Method |
Description |
public void display() |
In this method, displays
user details in the following order name, email, mobileNumber and address. |
Create class Doctor which inherits
User class
with the following private attributes/variables.
Data Type |
Variable |
String |
qualification |
int |
experience |
Include appropriate getters and setters.
Include parameterized constructor with parameters in the following order,
Doctor(String name, String email,
String mobileNumber, String address, String qualification, int experience)
In the Doctor class include the following method
Method |
Description |
public
void display() |
Calls the parent class display() and display the
doctor details. |
Create class Patient which inherits User class
with the following private attributes/variables.
Data
Type |
Variable |
String |
bloodGroup |
double |
height |
double |
weight |
Include appropriate getters and setters.
Include parameterized constructor with parameters in the following order, Patient(String name, String
email, String mobileNumber, String address, String bloodGroup, double height, double
weight)
In the Patient class include the following method
Method |
Description |
public
void display() |
Calls the parent class display() and display the
patient details. |
Create a driver class
Main. In the main
method, get user
details in CSV
format. Display the user details using the display()
method.
Input and
Output Format
Refer sample
input and output for formatting specifications.
All text in bold corresponds to the input and the rest corresponds to output.
Sample Input and Output 1:
Menu 1.Doctor 2.Patient 1
Enter the doctor
details(name,email,mobile number,address,qualification,experience) Albert,albert@gmail.com,7485961253,Canada,MBBS,5
Doctor details Name: Albert
Email: albert@gmail.com Mobile number: 7485961253 Address: Canada Qualification: MBBS Experience: 5
Sample Input
and Output 2:
Menu 1.Doctor 2.Patient 2
Enter the patient
details(name,email,mobile number,address,bloodGroup,height,weight) Jonas,jonas@gmail.com,9457961253,Canada,O+,165,55
Patient details Name: Jonas
Email: jonas@gmail.com Mobile number: 9457961253 Address: Canada BloodGroup: O+
Height:
165.0
Weight: 55.0
Sample Input
and Output 3:
Menu
1.Doctor
2.Patient 4
Invalid
input
public class Doctor extends User{
private String qualification;
private int experience;
public String getQualification() {
return qualification;
}
public void setQualification(String qualification) {
this.qualification = qualification;
}
public int getExperience() {
return experience;
}
public void setExperience(int experience) {
this.experience = experience;
}
public Doctor(String name,String email,String mobileNumber,String address,String qualification,int experience) {
super(name,email,mobileNumber,address);
this.qualification=qualification;
this.experience=experience;
}
public void display() {
super.display();
System.out.println("Qualification: "+qualification);
System.out.println("Experience: "+experience);
}
}
MOTIVATION :
“The way we spend our time defines who we are ”
Although we may not see each other as often as we’d like, distance is no match for the bond that we share. Thank you for coming to visit. It was fantastic to catch up.
VISITE MORE BLOGS