>>super
public class bos {
public int gaji;
public bos(int gaji){
this.gaji=gaji;
}
public void printbos(){
}
}
>>subclass1
public class direktur extends bos {
public direktur(int gaji){
super(gaji);
}
@Override
public void printbos(){
System.out.println("gaji direktur = "+super.gaji);
}
}
>>subclass2
public class manager extends bos {
public manager(int gaji){
super(gaji);
}
@Override
public void printbos(){
System.out.println("");
System.out.println("gaji manager = "+super.gaji);
}
}
>>subclass3
public class supervisor extends bos {
private int ceperan;
public supervisor(int gaji, int ceperan){
super(gaji);
this.ceperan=ceperan;
}
public void printbos(){
System.out.println("");
System.out.println("gaji supervisor = "+super.gaji);
System.out.println("dengan ceperan = "+ceperan);
System.out.println("total gaji = "+(super.gaji+ceperan));
}
}
>>subclass4
public class karyawan extends bos {
private int lembur;
public karyawan(int lembur, int gaji){
super(gaji);
this.lembur=lembur;
}
public void printbos(){
System.out.println("");
System.out.println("gaji karyawan = "+super.gaji);
System.out.println("dengan pendapatan lembur = "+lembur);
System.out.println("total gaji = "+(super.gaji+lembur));
}
}
>>class panggil
public static void main(String[] args) {
// TODO code application logic here
bos bos;
direktur dir=new direktur(15000000);
manager mag=new manager(10000000);
supervisor sup=new supervisor(5000000, 500000);
karyawan kar=new karyawan(300000, 2500000);
bos=dir;
bos.printbos();
bos=mag;
bos.printbos();
bos=sup;
bos.printbos();
bos=kar;
bos.printbos();
}
by : syifaus surur@112
Posted by 00.13 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar