🌙 DARK

Implementation of a Hospital management system using in Java

 

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





@MRProgrammer89 


CREATE CLASS < User :




public class User {
private String name,email,mobileNumber,address;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getMobileNumber() {
return mobileNumber;
}

public void setMobileNumber(String mobileNumber) {
this.mobileNumber = mobileNumber;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}
public User(String name,String email,String mobileNumber,String address) {
this.name=name;
this.email=email;
this.mobileNumber=mobileNumber;
this.address=address;
}
public void display() {
System.out.println("Patient details");
System.out.println("Name: "+name);
System.out.println("Mobile number: "+mobileNumber);
System.out.println("Address: "+address);
}

}


@MRProgrammer89 


CREATE CLASS < Doctor :



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);

}


}


@MRProgrammer89 


CREATE CLASS < Patient :





public class Patient extends User {
private String boodGroup;
private double height,weight;
public Patient(String name,String email,String mobileNumber,String address,String boodGroup,double height,double weight) {
super(name,email,mobileNumber,address);
this.boodGroup=boodGroup;
this.height=height;
this.weight=weight;
}

public String getBoodGroup() {
return boodGroup;
}

public void setBoodGroup(String boodGroup) {
this.boodGroup = boodGroup;
}

public double getHeight() {
return height;
}

public void setHeight(double height) {
this.height = height;
}

public double getWeight() {
return weight;
}

public void setWeight(double weight) {
this.weight = weight;
}
public void didplay() {
super.display();
System.out.println("BloodGroup: "+boodGroup);
System.out.println("Height: "+height);
System.out.println("Weight: "+weight);
}

}



@MRProgrammer89 


CREATE CLASS < Main :


import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Menu\n1.Doctor\n2.Patient");
int menu = sc.nextInt();
  if((menu)==1) {
System.out.println("Enter the doctor details(name,email,mobile number,address,qualification,experience)");
String detail = sc.next();
String details[]=detail.split(",");
String a = details[0];
String b = details[1];
String c = details[2];
String d = details[3];
String e = details[4];
int f = Integer.parseInt(details[5]);
Doctor obj = new Doctor(a,b,c,d,e,f);
obj.display();
  }
  else if(menu == 2) {
System.out.println("Enter the patient details(name,email,mobile number,address,bloodGroup,height,weight)");
String detail = sc.next();
String details[]=detail.split(",");
String a = details[0];
String b = details[1];
String c = details[2];
String d = details[3];
String e = details[4];
double f = Double.parseDouble(details[5]);
double g = Double.parseDouble(details[6]);
Patient obj1 = new Patient(a,b,c,d,e,f,g);
obj1.didplay();
}
else {
System.out.println("Invalid input");
}
}

}


@MRProgrammer89 






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




THANK YOU....😊





Post a Comment

Thanks for reading the blog. We hope it was useful to you and that you learned something new. Will always be writing on new and interesting topics, so you can visit our website to know the latest updates of our blogs. Thank You!

Previous Post Next Post

Contact Form