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

  • 0 0 0
  • Gefällt Ihnen dieses papier und der download? Sie können Ihre eigene PDF-Datei in wenigen Minuten kostenlos online veröffentlichen! Anmelden
Datei wird geladen, bitte warten...
Zitiervorschau

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 2017254658 2017224742 2017216808 2017216776

Date Submitted:

Name AHMAD ZHARIF BIN MOHD NAZARI NUR AISYAH HUDA BINTI ABDULLAH JOHARI WAN NUR ADLINA BINTI WAN BUANAN NURUL AMIRAH BINTI KARIM

1

3

1

1

2

2

0

1

8

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 - physician : String

Critical -specialist : String - static opRoom = 5000.00 : double

+ getPhysician() : String + setPhysician(String) : void + findDoctorFees() : double

+ getSpecialist () : String + getOpRoom() : 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) // {

// index++;

}

Read line for //

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