0% found this document useful (0 votes)
7 views

C Java Assignment

Uploaded by

easteak00987
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

C Java Assignment

Uploaded by

easteak00987
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

A Hospital Server Management System

Scenario: Ahospital server management system where patients can search for the best
doctors for their illnesses, and hospital management staff can add doctors and other
administrative staff using their ID and password.

Classes
1. ‘Person’ (Abstract Class)
Acts as a base class for all types of people in the hospital, defining common attributes and
methods. Contain an abstract method Details().

2. ‘Hospital_Employee’
Serves as an class for different types of employees in the hospital, inheriting from ‘Person’
and adding an ‘id’.

3. ‘Doctor’

Represents a doctor in the hospital, adding a specialization attribute and implementing the
abstract methods from ‘Hospital_Employee’.

4. ‘Management_Staff’

Represents a management staff member in the hospital, adding a password attribute and
implementing the abstract methods from ‘Hospital_Employee’.

5. ‘Patient’
Represents a patient in the hospital, inheriting from `Person` and adding an illness attribute.

6. ‘Server’
Provides various server functionalities to manage doctors, patients, and management staff,
including initializing arrays, creating new entries based on user input, and validating
credentials.
7. ‘Hospital_Management’
Acts as the entry point for the application, handling user input and coordinating interactions
between different components of the hospital management system.
UML Diagram

Hospital_Management
Server

- sc: Scanner
+ main(args: String[]): void
+ Server()
+ Server1(doctorArr: Doctor[]): void
+ Server2(): Patient
+ Server3(): Management_Staff
+ Server4(userId: int, passWord: int): int
+ Server5(Num: int, employeeArr: Hospital_Employee[]): void
+ Server6(Num: int, employeeArr: Hospital_Employee[]): void

Person

- name: String
- age: int
- gender: String

+ Person()
+ Person(name: String, age: int, gender: String)
+ Details(): void

Patient Hospital_Employee

- illness: String - id: int

+ Patient () + Hospital_Employee()
+ Patient(name: String, age: int, gender: String, illness: String ) + Hospital_Employee(name: String, age: int, gender: String)
+ Details(): void + Details(): void

Doctor Management_Staff

- passWord: int
- specialization: String
+ Management_Staff ()
+ Doctor () + Details(): void
+ Doctor(name: String, age: int, gender: String, specialization: String )
+ Doctor(id: int, name: String, age: int, gender: String, specialization: String )
+ Details(): void
package hospital_management;

/**

* @author Easteak

*/

public abstract class Person

private String name;


private int age;
private String gender;

Person()

//Set id, name, age, gender using Constructor.


public Person(String name, int age, String gender)
{

this.name = name;
this.age = age;
this.gender = gender;
}

//Get fun for name, age, gender.

public String getName()

return name;

public void setName(String name)

this.name = name;
}

//Set fun for id, name, age, gender.

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 abstract void Details();

package hospital_management;

/**
*
* @author Mugdho

*/

public class Patient extends Person

private String illness;

Patient()

public Patient(String name, int age, String gender, String illness)

super(name, age, gender);

this.illness = illness;

public String getIllness()

return illness;

public void setIllness(String illness) {


this.illness = illness;
}

public void Details()

{
System.out.println("Patient Name: " + getName() + "\nAge: " + getAge() + "\n Gender: " + getGender() +
"\n Illness: " + illness);

}
}
package hospital_management;

/**

* @author Mugdho

*/

public class Hospital_Employee extends Person

private int id;


public int getId()
{

return id;

public void setId(int id)

{ this.id
= id;
}

Hospital_Employee()

Hospital_Employee (String name, int age, String gender)

super(name, age, gender);

public void Details() {

}
package hospital_management;

/**
*

* @author Mugdho

*/

public class Doctor extends Hospital_Employee{

private String specialization;

Doctor()

public Doctor(String name, int age, String gender, String specialization)

super(name, age, gender);


this.specialization = specialization;
}

public Doctor(int id, String name, int age, String gender, String specialization)

super(name, age, gender);


super.setId(id); this.specialization
= specialization;
}

public void Details()

{
System.out.println("Doctor Name: " + getName() + "\nAge: " + getAge() + "\nGender: " + getGender() +
"\nSpecialization: " + specialization);

String getSpecialization()
{

return specialization;

package hospital_management;

/**

* @author Mugdho

*/

public class Management_Staff extends Hospital_Employee

int passWord;

Management_Staff()

public Management_Staff(int id, int passWord, String name, int age, String gender)

super(name, age, gender);


super.setId(id);
this.passWord=passWord;
}

public int getPassWord() {


return passWord;
}

public void Details(){


System.out.println("Id : " + getId() + "\nName: " + getName() + "\nAge: " + getAge() + "\nGender: " +
getGender());

}
}

package hospital_management;

package hospital_management; import


java.util.Scanner;
/**
*

* @author Mugdho

*/

public class Server

Scanner sc = new Scanner(System.in);

Server()

void Server1(Doctor[] doctorArr)

doctorArr[0]=new Doctor("Mugdho", 45, "Male", "Cardiology");


doctorArr[0].setId(4002);
doctorArr[1]=new Doctor("Shahadath", 50, "Male", "Orthopedics");
doctorArr[1].setId(4007);
doctorArr[2]=new Doctor("Partha", 40, "Male", "Neurology");
doctorArr[2].setId(4017);
}

Patient Server2()
{

String name; int age; String gender; String illness;


System.out.print("Enter Your\nName: ");
name=sc.nextLine(); System.out.print("Age: ");
age=sc.nextInt(); sc.nextLine();
System.out.print("Gender: ");
gender=sc.nextLine();
System.out.print("Wich type of specialize doctor you need according you illness: ");
illness=sc.nextLine();
Patient P1=new Patient(name, age, gender, illness);
return P1;
}

Management_Staff Server3()

Management_Staff M1 = new Management_Staff(4002, 1234, "Mugdho", 20, "Male");

return M1;

int Server4(int userId, int passWord)

if(userId==4002 && passWord==1234)

return 1;

else
{
return 0;

void Server5(int Num, Hospital_Employee[] employeeArr)

Hospital_Employee D1=new Doctor(4002, "Mugdho", 45, "Male", "Cardiology");


Hospital_Employee D2=new Doctor(407, "Shahadath", 50, "Male", "Orthopedics");
Hospital_Employee D3=new Doctor(4017, "Partha", 40, "Male", "Neurology");
employeeArr[0]=D1; employeeArr[1]=D2; employeeArr[2]=D3; for(int i=0; i<Num;
i++)
{

int id=0; String name; int age; String gender; String specialization;
System.out.print("Enter Doctor\nName:"); name=sc.nextLine();
System.out.print("Age:"); age=sc.nextInt(); sc.nextLine();
System.out.print("Gender:");
gender=sc.nextLine();
System.out.print("Specialization: ");
specialization=sc.nextLine();
System.out.println();

Doctor D4 =new Doctor(id, name, age, gender, specialization);


employeeArr[3+i]=D4;
}

void Server6(int Num, Hospital_Employee[] employeeArr)

//Management_Staff[] managementArr = new Management_Staff[Num+3];


Management_Staff M1 =new Management_Staff(4002, 1234, "Mugdho", 20, "Male");
employeeArr[0]=M1; for(int i=0; i<Num; i++)
{

int id=0; int passWord; String name; int age; String gender;
System.out.print("Enter \nName: "); name=sc.nextLine();
System.out.print("Age: "); age=sc.nextInt();
sc.nextLine();
System.out.print("Gender: ");
gender=sc.nextLine();
System.out.print("Id: ");
id=sc.nextInt();
sc.nextLine();
System.out.print("Password: ");
passWord=sc.nextInt();
sc.nextLine();
System.out.println();

Management_Staff M2 =new Management_Staff(id, passWord, name, age, gender);


employeeArr[1+i]=M2;
}

}
}

package hospital_management; import


java.util.Scanner;
/**
*

* @author Mugdho

*/

public class Hospital_Management

public static void main(String[] args)

Scanner sc = new Scanner(System.in);

System.out.println("Press 1 for Patient");

System.out.println("Press 2 for Management\n");

int press = sc.nextInt();


System.out.println();
Server S=new Server();

Doctor[] doctorArr = new Doctor[3];

if(press == 1)

S.Server1(doctorArr);

Patient P1=new Patient();


P1=S.Server2(); int
found=0; for(int i=0; i<3;
i++)
{

if(doctorArr[i].getSpecialization().equals(P1.getIllness()))

System.out.println();
doctorArr[i].Details();
System.out.println();
found = 1;
}

if(found==0) System.out.println("NO Doctor Found\n");

else if(press == 2)

System.out.print("Enter UserId : ");


int id = sc.nextInt();
System.out.print("Enter 4 Digit Password : ");
int passWord = sc.nextInt();
System.out.println();

Hospital_Employee M1=new Management_Staff();


M1=S.Server3(); if(S.Server4(id, passWord) == 1)
{

System.out.println("Press 1 for Add Doctor Information");


System.out.println("Press 2 for Add Management Information");
press=sc.nextInt();
System.out.println();
if(press==1)
{

System.out.print("Enter New Doctor Number: ");


int newE=sc.nextInt(); System.out.println();
Hospital_Employee[] employeeArr = new Hospital_Employee[newE+3];

S.Server5(newE, employeeArr);
System.out.println("Added");

else if(press==2)

System.out.print("Enter New Management_Staff Number: ");


int newE=sc.nextInt();
System.out.println();

Hospital_Employee[] employeeArr = new Hospital_Employee[newE+1];

S.Server6(newE, employeeArr);

System.out.println("Added");

}
}
else
{

System.out.println("Invalid UsereId or Password");

}
}

You might also like