0% found this document useful (0 votes)
33 views5 pages

Lab 1 SC&D

1) The document describes a Java code assignment to model a hospital management system based on a provided UML class diagram. 2) The code defines classes like Receptionist, Patient, Doctor, and Billing to represent different entities in the hospital management system. 3) The main method displays a menu and uses switch cases to allow choosing between receptionist, patient, and doctor options, with each class's choice method providing subclass-specific menus.

Uploaded by

Asad Ismail
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)
33 views5 pages

Lab 1 SC&D

1) The document describes a Java code assignment to model a hospital management system based on a provided UML class diagram. 2) The code defines classes like Receptionist, Patient, Doctor, and Billing to represent different entities in the hospital management system. 3) The main method displays a menu and uses switch cases to allow choosing between receptionist, patient, and doctor options, with each class's choice method providing subclass-specific menus.

Uploaded by

Asad Ismail
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/ 5

Lab # 1 SSUET/QR/114

LAB # 1

Introduction to Eclipse IDE

OBJECTIVE
Introduction to Eclipse IDE, creating projects, its classes and mapping UML class diagram in
to java code.

Lab Task:
Write the java code with the help of the given class diagram of Hospital Management
System.

SWE-312 Software Construction and Development


Lab # 1 SSUET/QR/114

Code:
import java.util.Scanner;
public class User {
public static void main(String[] args) {
System.out.println("Enter your choice:1)Receptionist 2)Patient
3)Doctor");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();
do {
switch (choice) {
case 1:
Receptionist R = new Receptionist();
R.choice();
break;
case 2:
Patient P = new Patient();
P.choice();
break;
case 3:
Doctor D = new Doctor();
D.choice();
break;
}
} while (choice != 4);
}
}

import java.util.Scanner;
class Receptionist extends User {
private int r_id;
private String r_name;
public void choice() {
System.out.println("Enter your choice: 1)GiveAppoint 2)GenerateBill");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();
switch (choice) {
case 1:
giveAppoint();
break;
case 2:
generateBill();
break;
case 3:
main(null);
}
}
public void generateBill() {
Billing B = new Billing();
int b_no = B.getB_no();
String p_name = B.getP_name();
int p_id = B.getP_id();
int b_amt = B.getB_amt();
System.out.println("BillNO: " + b_no + "\nPatientID: " + p_id + "\
nPatientName: " + p_name + "\nBillAmount: " + b_amt);
}
public void giveAppoint() {
Patient P = new Patient();
String p_name = P.getP_name();
int p_id = P.getP_id();

SWE-312 Software Construction and Development


Lab # 1 SSUET/QR/114

Doctor D = new Doctor();


int d_id = D.getD_id();
String d_name = D.getD_name();
System.out.println("\nPatientID: " + p_id + "\nPatientName: " + p_name +
"\nAppointment with Doctor \nDoctorID: " + d_id + "\nDoctorName" +
d_name);
}
}

import java.util.Scanner;
class Patient extends User {
private int p_id = 11;
private String p_name = "Sahil";
public void choice() {
System.out.println("Enter your choice: 1)PayBill");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();
switch (choice) {
case 1:
payBill();
break;
case 2:
main(null);
}
}
public int getP_id() {
return p_id;
}
public String getP_name() {
return p_name;
}
public void payBill() {
System.out.println("Thanks For Paying Bill");
}
}

import java.util.Scanner;
class Doctor extends User {
private int d_id = 12;
private String d_name = "Fahad";
public int getD_id() {
return d_id;
}
public String getD_name() {
return d_name;
}
public void choice() {
System.out.println("Enter your choice: 1)CheckPatient");
Scanner sc = new Scanner(System.in);
int choice = sc.nextInt();
switch (choice) {
case 1:
checkPatient();
break;
case 2:
main(null);
}
}
public void checkPatient() {
Patient P = new Patient();

SWE-312 Software Construction and Development


Lab # 1 SSUET/QR/114

String p_name = P.getP_name();


int p_id = P.getP_id();
System.out.println("Doctor: " + d_name + " has checked patient " +
p_name);
}
}

class Billing {
private int b_no = 201;
private int b_amt = 1000;
public String getP_name() {
Patient P = new Patient();
return P.getP_name();
}
public int getB_no() {
return b_no;
}
public int getB_amt() {
return b_amt;
}
public int getP_id() {
Patient P = new Patient();
return P.getP_id();
}
}

SWE-312 Software Construction and Development


Lab # 1 SSUET/QR/114

Output:

SWE-312 Software Construction and Development

You might also like