Last active
October 12, 2017 18:06
-
-
Save Rahandi/2c4c35a950a40c2130b2c516b3f3a11c to your computer and use it in GitHub Desktop.
Gaji
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DaftarGaji { | |
private Pegawai[] listPegawai; | |
private int jumlahPegawaiSekarang = 0; | |
public DaftarGaji(int jumlah_pegawai){ | |
listPegawai = new Pegawai[jumlah_pegawai]; | |
} | |
public void addPegawai(Pegawai p){ | |
listPegawai[jumlahPegawaiSekarang] = p; | |
jumlahPegawaiSekarang++; | |
} | |
public void printSemuaGaji(){ | |
for (int i=0;i<jumlahPegawaiSekarang;i++){ | |
System.out.print(listPegawai[i].getNama()+" mendapatkan gaji "); | |
System.out.println(listPegawai[i].getGaji()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Dosen extends Pegawai { | |
private int jumlahSKS; | |
private final int TARIF_SKS = 120000; | |
public Dosen(){ | |
} | |
public Dosen(String nip,String nama, String alamat){ | |
super(nip,nama,alamat); | |
} | |
public void setSKS(int SKS){ | |
this.jumlahSKS = SKS; | |
} | |
@Override | |
public int getGaji(){ | |
int total_gaji=jumlahSKS*TARIF_SKS; | |
return total_gaji+super.getGaji(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args){ | |
Staff s1=new Staff(); | |
s1.setNama("Bagus"); | |
s1.setKehadiran(10); | |
Dosen d1 = new Dosen(); | |
d1.setNama("Abdul"); | |
d1.setSKS(20); | |
Pegawai p1 = new Pegawai(); | |
p1.setNama("Sulton"); | |
DaftarGaji daftar_gaji=new DaftarGaji(3); | |
daftar_gaji.addPegawai(s1); | |
daftar_gaji.addPegawai(d1); | |
daftar_gaji.addPegawai(p1); | |
daftar_gaji.printSemuaGaji(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Pegawai { | |
private String nip; | |
private String nama; | |
private String alamat; | |
public Pegawai(){ | |
} | |
public Pegawai(String nama,String nip, String alamat) | |
{ | |
this.nama=nama; | |
this.nip=nip; | |
this.alamat=alamat; | |
} | |
public void setNama(String nama){ | |
this.nama=nama; | |
} | |
public String getNama(){ | |
return this.nama; | |
} | |
public int getGaji(){ | |
return 1500000; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Staff extends Pegawai | |
{ | |
private int jumlah_kehadiran; | |
private final int TARIF_HARIAN = 50000; | |
public Staff(){ | |
} | |
public Staff (String nip,String nama, String alamat){ | |
super(nip,nama,alamat); | |
} | |
public void setKehadiran(int jumlah_kehadiran){ | |
this.jumlah_kehadiran=jumlah_kehadiran; | |
} | |
@Override | |
public int getGaji(){ | |
int total_gaji=jumlah_kehadiran*TARIF_HARIAN; | |
return total_gaji+super.getGaji(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment