Tugas Array dan inhertance Kelompok 15


KELOMPOK 15 SI-40-03

AULIA IRSYAD (1202160155)

CHANDRA ADHITYA (12021160229)

FEBRIAN RIZKY(1202160262)

MUHAMAD FARHAN ADITYA (1202164027)

Nomor 5.(hal:648 Inhertance)

A. Defines two classes Patient and Billing, whose objects are records for a clinic. Derive Patient from the class Person given in listing . 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 Patientobject 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, then 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.

B. Penjelasan Soal:

Definisikan dua kelas ,Pasien dan Tagihan, setiap objek adalah catatan untuk klinik. Turunkan Pasien dari class Person yang diberikan dalam daftar. Catatan Pasien harus memiliki nama pasien (didefinisikan dalam kelas Person) dan identifikasi nomor (menggunakan jenis String). Objek Penagihan akan berisi Object Pasien dan Objek Dokter (dari Programming Project 4). Berikan kelas pelengkap wajar konstruktor dan metode accessor,dan sama metode juga. Pertama menulis sebuah program driver untuk menguji semua Anda metode, kemudian menulis sebuah program tes yang menciptakan setidaknya dua pasien, setidaknya dua dokter, dan setidaknya dua catatan Penagihan dan kemudian menampilkan total pendapatan dari catatan Penagihan

C. Script Code :

1.

package adjajda;

class Person {String name;

String ID;

String name2;

String ID2;

public Person( )

{

name = “MAMAN NURAHMAN”;

ID = “12225487”;

name2=”JAJANG SURAJANG”;

ID2=”122235488″;

}

public void writeOutput( )

{System.out.println(“=== DATA PASIEN ===”);

System.out.println(“1. NAMA : ” + name);

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

System.out.println(“2. NAMA :”+ name2);

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

}

}

2.

package adjajda;

class Doctor extends Person{

String name;

String s;

double g;

double Fee;

double total;

String name2;

String s2;

double g2;

double Fee2;

double tot;

public Doctor() {

name =” dr. Aliando, Sp.OG” ;

s=”Pintar dan Ramah”;

g=2500000;

Fee=50000;

total = g+Fee;

name2=”drg.Lulu lila”;

s2=”Cantik dan Pintar”;

g2=3000000;

Fee2=200000;

tot= g2+Fee2;

}

public void writeOutput(){

System.out.println(“=== DATA DOKTER ===”);

System.out.println(” DOKTER 1 : “+name);

System.out.println(“KEAHLIAN : “+s);

System.out.println(“GAJI : “+g);

System.out.println(“TOTAL BIAYA : “+total);

System.out.println(” DOKTER 1 : “+name2);

System.out.println(“KEAHLIAN : “+s2);

System.out.println(“GAJI : “+g2);

System.out.println(“TOTAL BIAYA : “+tot);

}}

3.

package adjajda;

class billing {public static void main(String[] args) {

Person a = new Person();

a.writeOutput();

Doctor b = new Doctor();

b.writeOutput();

}

}

D. Screenshot OUTPUT


Leave a Reply