Breaking News
Loading...
Wednesday, 23 October 2013

Info Post
Silahkan kalian perbaiki kode program yang masih error tentang inheritance dibawah, hapus kode kode yang memang dirasa tidak digunakan dan kata kuncinya (*perbaiki programnya, bukan merubah format susunan programnya*). Jika kurang paham silahkan tanya via sms saja.
==================================================================
package tugas_modul2;


public class Pegawai {
    private String nama;
    private String nip;
    private String golongan;
   
    public Pegawai(String nama,String nip,String gol){
        this.nama=nama;
        this.nip=nip;
        this.golongan=gol;
    }
    public void set_golongan(String gol){
        this.golongan=gol;
    }
    public void tampil_data_pegawai(){
        System.out.println("nama ="+nama);
        System.out.println("nip ="+nip);
        System.out.println("golongan ="+golongan);
    }
}

==================================================================

package tugas_modul2;

public class Data_gaji extends Pegawai{

    public Data_gaji(String nama, String nip, String gol) {
        super(nama, nip,gol);       
    }
   
    private void hitung_gaji(){
        if("A".equals(super.golongan)){
            System.out.println("gaji = Rp. 3.000.000");
        }
        else if("B".equals(super.golongan)){
            System.out.println("gaji = Rp. 2.000.000");
        }
    }
}

==================================================================

package tugas_modul2;

public class pegawai1{
    int gaji;
    public pegawai1(String nama,String nip, String gol) {
        super(nama, nip, gol);
    }
   
    @Override
    public void set_golongan(String gol) {
        super.set_golongan(gol);
    }
   
    public void hitung_gaji(){
        if("A".equals(super.golongan)){
            System.out.println("gaji =  "+gaji);
        }
        else if("B".equals(super.golongan)){
            System.out.println("gaji = "+gaji);
        }
    }
   
    public void tampil(){
        super.tampil_data_pegawai();
        this.hitung_gaji();
        System.out.println("====================");
    }
}
==================================================================

package tugas_modul2;

public class Tugas_modul2 {
   
    public static void main(String[] args) {
        pegawai1 peg=new pegawai1("joe satriani","1104","B");
        peg.tampil();
        pegawai1 peg2=new pegawai1("mike portnoy","1105","A");
        peg2.tampil();
    }
}
==================================================================

0 comments:

Post a Comment