Mini Project - Final Report: Object Oriented Programming (CSC238)
Mini Project - Final Report: Object Oriented Programming (CSC238)
OBJECT ORIENTED
PROGRAMMING
(CSC238)
Team Members:
Student ID Name
2017254658 AHMAD ZHARIF BIN MOHD NAZARI
2017224742 NUR AISYAH HUDA BINTI ABDULLAH JOHARI
2017216808 WAN NUR ADLINA BINTI WAN BUANAN
2017216776 NURUL AMIRAH BINTI KARIM
Date Submitted: 1 3 1 2 2 0 1 8
1
Table of Contents
Acknowledgement……………………………………………………………………..………3
Executive Summary………………………………………………………………………... …4
Object Design………………………………………………………………………………….5
Source Codes…………………………………………………………………………………..6
References……………………………………………………………………………………23
2
Acknowledgement
We would like to express our special thanks of gratitude to our lecturer Siti ‘Aisyah
Binti Sa’adan who gave the golden opportunity to do this wonderful project as well as to our
leader Ahmad Zharif Bin Mohd Nazri who distribute work for each of the members. Thank
you again to our lecturer who also help us doing this project. We do a lot of research and all of
us came to know about so many new things and we truly really thankful for them who help us.
Then, we also would like to thank you to our classmates who helped us a lot in finalizing
this project within the limited time framed and support us from behind.
3
Executive Summary
Our project is to about implementation for a Patient program. A research has been made
and we found that a lot of hospital did not use online registration. From this analysis we
decided to design a program to help hospital business operation work efficiently.
When the hospital use manual registration, it makes the employees at the hospital out of
hand because of lot of patients. Besides that the hospital use manual registration that they
must keep their patients record and the probability for documents to missing is high.
Our objectives for this program is to do calculation to find summation for patient total bill,
to find maximum highest total bill, and to search patient with heart attack disease. In this
program, we use inheritance, polymorphism and input/output file.
We using an abstract class for the patient class and having a sub class which is non-critical
or critical patients. We also using input/output file that have name, id, illness, nationality,
wards and how many days did the patients stay in the hospital.
Next, it will display the patient's information. In the main, we using the polymorphism as
the instanceof to critical and non-critical patient. We also get their information about either
the patient is Malaysian or foreigner.
The program will display the wards class either the patient take first class, second class or
the third class. Moreover, after we know the wards class we will calculate the patient fee. The
calculation are the wards class times with the number of the days did the patient stay in the
hospital.
The program will find the highest total bill. Then, it will display the information of the
patient. The program also do the searching for the patients' information. After doing the
searching, the program will display the information.
4
Object Design
Patient
{abstract}
-name : String
-id : String
-illness : String
-nationality : String
-wards : int
-days : int
+Patient(String, String, String, String, int, int)
+ getName() : String
+ getID() : String
+ getillness() : String
+ getNationality() : String
+ getWards() : int
+ getDays() : int
+ setName(String) : void
+ setID(String) : void
+ setIllness(String) : void
+ setNationality(String) : void
+ setWards(int) : void
+ setDays(int) : void
+ findDoctorFees() : double { abstract}
+ findFees() : double
+ displayInfo() : void
Non_Critical Critical
- physician : String -specialist : String
- static opRoom = 5000.00 : double
+ getPhysician() : String + getSpecialist () : String
+ setPhysician(String) : void + getOpRoom() : double
+ findDoctorFees() : double + setSpecialist(String) : void
+ findDoctorFees() : double
5
Source Codes
PATIENT CLASS
//normal constructor
public Patient(String n, String i, String ill, String nat, int w, int d)
{
name = n;
id = i;
illness = ill;
nationality = nat;
wards = w;
days = d;
}
//accessor
public String getName()
{ return name; }
6
public String getNationality()
{ return nationality; }
//mutator
public void setName(String n)
{ name = n; }
//process
public abstract double findDoctorFees();
double fees=0.0;
public double findFees()
{
7
if (wards==1)
{
fees = 550 * days;
}
else if (wards==2)
{
fees = 300 * days;
}
else if (wards==3)
{
fees = 120 * days;
}
else
{
System.out.println("Invalid value");
}
if(nationality.equals("Malaysia"))
{
fees += 0.00;
}
else
{
fees += 50.00;
}
return fees;
}
//print
public void displayInfo()
{
8
System.out.println("Patient's Name: " + name);
System.out.println("Patient's ID: " + id);
System.out.println("Illness: " + illness);
System.out.println("Nationality: " + nationality);
if(wards==1){System.out.println("Wards : First Class "); }
if(wards==2){System.out.println("Wards : Second Class "); }
if(wards==3){System.out.println("Wards : Third Class "); }
System.out.println("Days admited: " + days);
}
9
NON_CRITICAL CLASS
public Non_Critical(String n, String i, String ill, String nat, int w, int d, String phy)
{
super(n, i, ill, nat, w, d);
physician = phy;
}
10
CRITICAL CLASS
public class Critical extends Patient
{
private String specialist;
private static double opRoom = 5000.00;
public Critical (String n, String i, String ill, String nat, int w, int d, String s)
{
super(n,i,ill,nat,w,d);
specialist = s;
}
public String getSpecialist ()
{
return specialist;
}
11
PATIENT APP
import java.util.*;
import java.io.*;
int index=0;
12
String name = st.nextToken();
String id = st.nextToken();
String illness = st.nextToken();
String nationality = st.nextToken();
int wards = Integer.parseInt(st.nextToken());
int days = Integer.parseInt(st.nextToken());
boolean critical = Boolean.parseBoolean(st.nextToken());
if (critical==true)
{
String specialist = st.nextToken();
p[count]=new Critical(name,id,illness,nationality,wards,days,specialist);
}
else
{
String physician = st.nextToken();
p[count]=new Non_Critical(name,id,illness,nationality,wards,days,physician);
}
count++;
}
// to calculate total bill, and print all the patients information in the output file
(Receipt.txt).
for (int i=0; i<index; i++)
{
double totalBill = 0.0;
pw.println("------------------------Patient's Information------------------------");
pw.println("Patient's Name: " + p[i].getName());
pw.println("Patient's ID: " + p[i].getID());
13
pw.println("Illness : " + p[i].getillness());
pw.println("Nationality: " +p[i].getNationality());
pw.println("Ward (Class): " +p[i].getWards());
pw.println("Day(s) Admited : " +p[i].getDays());
if (p[i].getWards()==1)
{
pw.println("First Class: RM550.00");
}
else if (p[i].getWards()==2)
14
{
pw.println("Second Class: RM300.00");
}
else
{
pw.println("Third Class: RM120.00");
}
if(p[i].getNationality().equals("Malaysia"))
{
pw.println("Malaysian: No Extra Fee");
}
else
{
pw.println("Foreigner: RM50.00");
}
if (highest<totalBill) //
{ // to find highest total bill,
highest = totalBill; // and find index for highest total bill.
h = i; //
} //
System.out.println("--------------------Highest Payment--------------------");//
p[h].displayInfo(); // display the highest total bill
System.out.println("Total Bill: RM" + highest); // at screen console
15
System.out.println("\n\n");
// Find t patient who had heart attack and display the patient information
int found = -1;
for (int i=0; i<index; i++)
{
if(p[i].getillness().equalsIgnoreCase("Heart Attack"))
{found = i;}
}
System.out.println("--------------------Hospital Raub--------------------");
if (found!=-1)
{p[found].displayInfo();}
br.close();
pw.close();
}
catch(FileNotFoundException e)
{
System.out.println ("Problem : " + e.getMessage());
}
catch(IOException ioe)
{
System.out.println ("Problem : " + ioe.getMessage());
}
}
16
Details of Input and Output File
PatientForm.txt
Receipt.txt
------------------------Patient's Information------------------------
Illness : Fever
Nationality: Malaysia
Ward (Class): 3
Day(s) Admited : 3
17
------------------------Patient's Bill-------------------------
Physician: RM1000.00
------------------------Patient's Information------------------------
Nationality: Malaysia
Ward (Class): 2
Day(s) Admited : 10
-----------------------Patient's Bill-------------------------
Specialist: RM5000.00
18
------------------------Patient's Information------------------------
Nationality: Malaysia
Ward (Class): 1
Day(s) Admited : 12
-----------------------Patient's Bill-------------------------
Specialist: RM5000.00
19
------------------------Patient's Information------------------------
Nationality: Indonesian
Ward (Class): 3
Day(s) Admited : 1
------------------------Patient's Bill-------------------------
Physician: RM1000.00
Foreigner: RM50.00
20
Sample Input/Output (Snapshot)
21
Sample output at console
22
References
23