Revisi Tugas Inhertance kelompok 5_SI4003


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.

Penjelasan :
Membuat Inteherance Passien sebagai Person,doctor dan billing. Objek Penagihan akan berisi Object Pasien dan Objek Dokter (dari Programming Project ). 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

Source Code :

import java.util.Scanner;
class Person {
String name;
String ID;
String name2;
String ID2;
int keluhan;
public orang() {
Scanner hehe = new Scanner(System.in);
System.out.print("Nama Anda: ");
name = hehe.nextLine();
System.out.print("Nommor Telphone: ");
ID = hehe.nextLine();
System.out.println("Keluhan : ");
System.out.println("1. Sakit Mata");
System.out.println("2. Sakit Hati");
keluhan=hehe.nextInt();
}
public void writeOutput() {
Scanner hehe = new Scanner(System.in);
System.out.println("*** Data Pasien ***");
System.out.println("1. NAMA : " + name);
System.out.println(" ID : " + ID);
if (keluhan == 1) {
Doctor d = new Doctor();
System.out.println("Keluhan Anda : Sakit Matai");
System.out.println("Dokter Anda : Fahri Mad");
System.out.println("Biaya berobat anda adalah : Rp.219.000,00");
d.doktergigi();
} else if (
keluhan == 2) {
Doctor d = new Doctor();
System.out.println("Keluhan Anda : Sakit Hati");
System.out.println("Dokter Anda : dr Asep Hidayat");
System.out.println("Biaya berobat anda adalah : Rp.217.000,00");
d.dokterkepala();
}
}
}

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 void dktr() {
name =" dr. Fahri Mad" ;
s="Baik Sekali";
g=2000000;
Fee=19000;
total = g+Fee;
name2="drg.Asep Hidayat";
s2="Ganteng Pisan";
g2=2000000;
Fee2=170000;
tot= g2+Fee2;
}
public void dokterkepala(){
System.out.println("**DATA DOKTE**");
System.out.println(" DOKTER 1 : "+name);
System.out.println("KEAHLIAN : "+s);
System.out.println("GAJI : "+g);
System.out.println("TOTAL BIAYA : "+total);
}
public void doktergigi(){
System.out.println(" DOKTER 2 : "+name2);
System.out.println("KEAHLIAN : "+s2);
System.out.println("GAJI : "+g2);
System.out.println("TOTAL BIAYA : "+tot);
}}

class billing {public static void main(String[] args) {
Person a = new Person();
a.orang();
a.writeOutput();
Doctor b = new Doctor();
}
}

ss code


Leave a Reply