Created
December 19, 2020 08:37
-
-
Save PhilipPurwoko/aef47d2020f4b85e4dcbe9a83bde74ca to your computer and use it in GitHub Desktop.
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
package inheritance; | |
public class Dosen extends Pegawai { | |
long gatun = 1000000; | |
void hitungGatun(){ | |
System.out.print("Gaji Tunjangan : "); | |
System.out.println(this.namaPegawai + " " + this.gatun); | |
} | |
void hitungGatot(){ | |
System.out.print("Gaji Total : "); | |
System.out.println(this.namaPegawai + " " + (this.gapok+this.gatun)); | |
} | |
} |
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
package inheritance; | |
public class Inheritance { | |
public static void main(String[] args) { | |
Pegawai philip = new Pegawai(); | |
philip.namaPegawai = "Philip"; | |
philip.kodePegawai = "K3519066"; | |
philip.golPegawai = "A"; | |
philip.hitungGapok(); | |
Dosen purwoko = new Dosen(); | |
purwoko.namaPegawai = "Purwoko"; | |
purwoko.kodePegawai = "K3519100"; | |
purwoko.golPegawai = "B"; | |
purwoko.hitungGapok(); | |
purwoko.hitungGatun(); | |
purwoko.hitungGatot(); | |
} | |
} |
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
package inheritance; | |
public class Pegawai { | |
String kodePegawai; | |
String namaPegawai; | |
String golPegawai; | |
long gapok = 2000000; | |
void hitungGapok(){ | |
System.out.print("Gaji Pokok : "); | |
System.out.println(this.namaPegawai + " " + this.gapok); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment