langsung saja ni kodingannya.
>>superclass
public class bos {
protected int keuntungan;
protected int gaji;
public void printbos(){
gaji=keuntungan;
System.out.println("");
}
public void printkeuntungan(){
keuntungan=250000000;
System.out.println("jumlah keuntungan = "+keuntungan);
}
}
>>sub class 1
public class direktur extends bos {
direktur(){
System.out.println("");
}
public void printbos(){
System.out.println("gaji direktur = "+(50000000/100*30));
}
}
>>subclass2
public class manager extends bos {
manager(){
System.out.println("");
}
public void printbos(){
System.out.println("gaji manager = "+(50000000/100*20));
}
}
>>subclass3
public class supervisor extends bos {
private int ceperan=500000;
supervisor(){
System.out.println("");
}
public void printbos(){
int a=50000000/100*10;
System.out.println("gaji supervisor = "+(a));
System.out.println("dengan pendapatan ceperan = "+ceperan);
System.out.println("total gaji = "+(a+ceperan));
}
}
>>subclass4
public class karyawan extends bos {
private int lembur=250000;
karyawan(){
System.out.println("");
}
public void printbos(){
int a=50000000/100*5;
System.out.println("gaji karyawan = "+(a));
System.out.println("dengan pendapatan lembur = "+lembur);
System.out.println("total gaji = "+(a+lembur));
}
}
>>class panggil
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
bos bos=new bos();
direktur dir=new direktur();
manager mag=new manager();
supervisor sup=new supervisor();
karyawan kar=new karyawan();
bos.printkeuntungan();
System.out.println("");
bos=dir;
bos.printbos();
System.out.println("");
bos=mag;
bos.printbos();
System.out.println("");
bos=sup;
bos.printbos();
System.out.println("");
bos=kar;
bos.printbos();
}
}
by : syifaus surur@112
Posted by 00.07 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar