0% found this document useful (0 votes)
1K views

Mini Project - Final Report: Object Oriented Programming (CSC238)

This is a final report that a sample as for those who wants to refer for Compter Science course CSC238.

Uploaded by

Wan adlina
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Mini Project - Final Report: Object Oriented Programming (CSC238)

This is a final report that a sample as for those who wants to refer for Compter Science course CSC238.

Uploaded by

Wan adlina
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

UNIVERSITI TEKNOLOGI MARA

27600 Raub, Pahang

FACULTY OF COMPUTER AND MATHEMATICAL SCIENCES


Fakulti Sains Komputer dan Matematik

OBJECT ORIENTED
PROGRAMMING
(CSC238)

MINI PROJECT – FINAL REPORT

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

Details of Input and Output File……………………………………………………………...17

Sample Input/Output (Snapshot)……………………………………………………………. 21

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

public abstract class Patient


{
private String name;
private String id;
private String illness;
private String nationality;
private int wards;
private int days;

//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; }

public String getID()


{ return id; }

public String getillness()


{ return illness; }

6
public String getNationality()
{ return nationality; }

public int getWards()


{ return wards; }

public int getDays()


{ return days; }

//mutator
public void setName(String n)
{ name = n; }

public void setID(String i)


{ id = i; }

public void setIllness(String w)


{ illness = w; }

public void setNationality(String nat)


{ nationality = nat; }

public void setWards(int w)


{ wards = w;}

public void setDays(int d)


{ days = d; }

//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 class Non_Critical extends Patient


{
private String physician;

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

public String getPhysician()


{
return physician;
}

public void setPhysician(String phy)


{
physician = phy;
}

public double findDoctorFees()


{
double fees = 0.0;
fees = 1000.00;
return fees;
}
}

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

public double getOpRoom()


{
return opRoom;
}

public void setSpecialist(String s)


{
specialist = s;
}

public double findDoctorFees()


{
double fees = 0.0;
fees = 5000.00;
return fees;
}

11
PATIENT APP
import java.util.*;
import java.io.*;

public class PatientApp


{
public static void main (String[] args)
{
try
{
FileReader fr = new FileReader ("PatientForm.txt");// Input
BufferedReader br = new BufferedReader (fr); // File

FileWriter fw = new FileWriter ("Receipt.txt");//


BufferedWriter bw = new BufferedWriter (fw); // Output file
PrintWriter pw = new PrintWriter (bw); //

int index=0;

String input = null; //


while (br.readLine()!=null) //
{ // Read line for
index++; // number of input
} //
br.close(); //

//-------------------------Read line input from file-----------------------------------


fr = new FileReader ("PatientForm.txt");
br = new BufferedReader (fr);
Patient[] p = new Patient[index];
int count=0;
while((input = br.readLine())!=null)
{
StringTokenizer st = new StringTokenizer(input,";");

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++;
}

int h = 0; // to find index for highest total bill


double highest = 0.0; // to find highest total bill

// 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] instanceof Critical)


{
Critical tempC = (Critical) p[i];
pw.println("Patient's Condition: Critical");
pw.println("Specialist: " + tempC.getSpecialist());
pw.println(" ");
pw.println("-----------------------Patient's Bill------------------------- ");
pw.println("Specialist: RM5000.00");
pw.println("Operating Room: RM5000.00");
totalBill = (p[i].findFees() + p[i].findDoctorFees() + tempC.getOpRoom());
}

else if (p[i] instanceof Non_Critical)


{
Non_Critical tempNon = (Non_Critical) p[i];
pw.println("Patient's Condition: Non-Critical");
pw.println("Phycsician: " + tempNon.getPhysician());
pw.println(" ");
pw.println("------------------------Patient's Bill------------------------- ");
pw.println("Physician: RM1000.00");
totalBill = p[i].findFees() + p[i].findDoctorFees();
}

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; //
} //

pw.println("Total Bill: RM" + totalBill);


pw.println("\n\n");

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

else {System.out.println("Patient's information does not found");}

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

Nurul Huda;991116065018;Fever;Malaysia;3;3;false;DR Majmun binti Kulim;

Siti Adlina;990615106510;Heart Attack;Malaysia;2;10;true;DR Zharif bin Nazari


(Cardiologist);

Syarifah Amirah;990618065320;Bone Fractured;Malaysia;1;12;true;DR Alif Danial bin


Rustam (Orthopaedics);

Alif Asyraf;990211063487;head ache;Indonesian;3;1;false;DR Haikal bin Haizad;

Receipt.txt

------------------------Patient's Information------------------------

Patient's Name: Nurul Huda

Patient's ID: 991116065018

Illness : Fever

Nationality: Malaysia

Ward (Class): 3

Day(s) Admited : 3

Patient's Condition: Non-Critical

Phycsician: DR Majmun binti Kulim

17
------------------------Patient's Bill-------------------------

Physician: RM1000.00

Third Class: RM120.00

Malaysian: No Extra Fee

Total Bill: RM1360.0

------------------------Patient's Information------------------------

Patient's Name: Siti Adlina

Patient's ID: 990615106510

Illness : Heart Attack

Nationality: Malaysia

Ward (Class): 2

Day(s) Admited : 10

Patient's Condition: Critical

Specialist: DR Zharif bin Nazari (Cardiologist)

-----------------------Patient's Bill-------------------------

Specialist: RM5000.00

Operating Room: RM5000.00

Second Class: RM300.00

Malaysian: No Extra Fee

Total Bill: RM13000.0

18
------------------------Patient's Information------------------------

Patient's Name: Syarifah Amirah

Patient's ID: 990618065320

Illness : Bone Fractured

Nationality: Malaysia

Ward (Class): 1

Day(s) Admited : 12

Patient's Condition: Critical

Specialist: DR Alif Danial bin Rustam (Orthopaedics)

-----------------------Patient's Bill-------------------------

Specialist: RM5000.00

Operating Room: RM5000.00

First Class: RM550.00

Malaysian: No Extra Fee

Total Bill: RM16600.0

19
------------------------Patient's Information------------------------

Patient's Name: Alif Asyraf

Patient's ID: 990211063487

Illness : head ache

Nationality: Indonesian

Ward (Class): 3

Day(s) Admited : 1

Patient's Condition: Non-Critical

Phycsician: DR Haikal bin Haizad

------------------------Patient's Bill-------------------------

Physician: RM1000.00

Third Class: RM120.00

Foreigner: RM50.00

Total Bill: RM1170.0

20
Sample Input/Output (Snapshot)

sample output in file

21
Sample output at console

22
References

 Y.Daniel Liang. (2018). Introduction to Java Programming and Data Structure.


Eleventh Edition.
 Slide notes from Siti 'Aisyah Binti Sa'adan.

23

You might also like