Tugas Array dan Inheritance Kelompok 15


TUGAS ARRAY KELOMPOK 15

Soal

Define two classes, Patient and Billing, whose objects are records for a clinic. Derive Patient from the class Person given in Listing 8.1. A Patient record has the patient’s name (defined in the class Person) and identification number (use the type String). A Billing object will contain a Patient object and a Doctor object (from Programming Project 4). Give your classes a reasonable complement of constructors and accessor methods, and an equals method as well. First write a driver program to test all your methods, the write a test program that creates at least two patients, at least two doctors, and at least two Billing records and then displays the total income from the Billing records.

Penjelasan Soal

Soal ini mengharuskan kita untuk membuat 3 class, yaitu class person, class dokter, dan class billing. Pada class person terdapat data pasien yang berupa nama dan IDE yang memiliki type data string. Pada class dokter terdapat data dokter yang terdiri dari nama dokter, spesialisasi nya, tagihan pertama dan kedua nya, dan total pemasukan nya. Pada class billing berfungsi sebagai main class.

Source Code

class Person {

String Nama, ID, Nama2, ID2;

public Person ()

{ Nama = "Ishak";

ID = "1202164371";

Nama2 = "Nitho";

ID2 = "1202162310";

}

public void writeOutput () {

System.out.println("—-Data Pasien—-");

System.out.println(" Nama : " + Nama);

System.out.println(" ID : " + ID);

System.out.println("");

System.out.println(" Nama : " + Nama2);

System.out.println(" ID : " + ID2);

}

}

class Dokter extends Person {

String NamaD, NamaD2, ahli, ahli2;

double feex, feex2, totalx, feey, feey2, totaly;

public Dokter(){

NamaD = "dr. Luthfi Sp.PD";

ahli = "Spesialis Penyakit Dalam";

feex = 1000000;

feex2 = 1500000;

totalx = feex + feex2;

NamaD2 = "dr. Hafiz Sp.M";

ahli2 = "Spesialis Mata";

feey = 2000000;

feey2 = 2300000;

totaly = feey + feey2;

}

public void writeOutput(){

System.out.println("");

System.out.println("—-Data Dokter—-");

System.out.println(" Dokter : " + NamaD);

System.out.println(" Spesialis : " + ahli);

System.out.println(" Tagihan pertama : " + feex );

System.out.println(" Tagihan kedua : " + feex2 );

System.out.println(" Total pemasukan " + totalx);

System.out.println("");

System.out.println(" Dokter : " + NamaD2);

System.out.println(" Spesialis : " + ahli2);

System.out.println(" Tagihan pertama : " + feey);

System.out.println(" Tagihan kedua : " + feey2);

System.out.println(" Total pemasukan : " + totaly);

}

}

class Tagihan {

public static void main(String[] args) {

Person a = new Person();

a.writeOutput();

Dokter b = new Dokter();

b.writeOutput();

}

}


Kelompok 15 SI-40-02 :

· Muhammad Ishak Syukri 1202164371

· Zenitho Madyagantang 1202162310

· M Luthfi Ridhwan 1202160353

· Hafiz Afandi 1202150030


Leave a Reply