Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS11-1941720240-Addina Nurul Mawaddah #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package interfacelatihan;

public interface IBerprestasi {
public abstract void menjuaraiKompetisi();
public abstract void membuatPublikasiIlmiah();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package interfacelatihan;

public interface ICumlaude {
public abstract void lulus();
public abstract void meraihIPKTinggi();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package interfacelatihan;

public class Interfacemain {
public static void main(String[] args) {
Rektor pakRektor = new Rektor();

// Mahasiswa mahasiswaBiasa = new
// Mahasiswa("Charlie");
Sarjana sarjanaCumlaude = new Sarjana("Dini");
PascaSarjana masterCum = new PascaSarjana("Elok");

// PascaSarjana("Elok");
// pakRektor.beriSertifikatCumlaude(mahasiswaBiasa);
// pakRektor.beriSertifikatMawapres(sarjanaCum);
pakRektor.beriSertifikatMawapres(masterCum);
}
}
14 changes: 14 additions & 0 deletions 1941720240_Addina Nurul Mawaddah/interfacelatihan/Mahasiswa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package interfacelatihan;

public class Mahasiswa {
protected String nama;

public Mahasiswa(String nama){
this.nama = nama;
}

public void kuliahDikampus(){
System.out.println("Aku mahasiswa, namaku " + this.nama);
System.out.println("Aku berkuliah dikampus.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package interfacelatihan;

public class PascaSarjana extends Mahasiswa implements ICumlaude, IBerprestasi{
public PascaSarjana(String nama){
super(nama);
}

@Override
public void lulus(){
System.out.println("Aku sudah menyelesaikan TESIS");
}

@Override
public void meraihIPKTinggi(){
System.out.println("IPK-ku lebih dari 3,71");
}

@Override
public void menjuaraiKompetisi(){
System.out.println("Ssaya telah menjuarai kompetisi INTERNASIONAL");
}

@Override
public void membuatPublikasiIlmiah(){
System.out.println("Saya menerbitkan artikel di jurnal INTERNASIONAL");
}
}
20 changes: 20 additions & 0 deletions 1941720240_Addina Nurul Mawaddah/interfacelatihan/Rektor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package interfacelatihan;

public class Rektor {
public void beriSertifikatCumlaude(ICumlaude mahasiswa){
System.out.println("Saya REKTOR, memberikan sertifikat cumlaude");
System.out.println("Selamat! bagaimana anda bisa cumlaude?");

mahasiswa.lulus();
mahasiswa.meraihIPKTinggi();
System.out.println("------------------------------------------");
}

public void beriSertifikatMawapres(IBerprestasi mahasiswa){
System.out.println("Saya REKTOR, memberikan sertifikat MAWAPRESS");
System.out.println("Selamat! bagaimana anda bisa berprestasi?");
mahasiswa.menjuaraiKompetisi();
mahasiswa.membuatPublikasiIlmiah();
System.out.println("------------------------------------------");
}
}
17 changes: 17 additions & 0 deletions 1941720240_Addina Nurul Mawaddah/interfacelatihan/Sarjana.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package interfacelatihan;

public class Sarjana extends Mahasiswa implements ICumlaude{
public Sarjana(String nama){
super(nama);
}

@Override
public void lulus(){
System.out.println("Aku sudah menyelesaikan SKIRPSI");
}

@Override
public void meraihIPKTinggi(){
System.out.println("IPK-ku lebih dari 3,51");
}
}
29 changes: 29 additions & 0 deletions 1941720240_Addina Nurul Mawaddah/tugasinterface/Binatang.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package tugasinterface;

public abstract class Binatang {
protected String nama;
protected int jmlKaki;

public Binatang(String nama, int jmlKaki) {
this.nama = nama;
this.jmlKaki = jmlKaki;
}

public String getNama() {
return nama;
}

public void setNama(String nama) {
this.nama = nama;
}

public int getJmlKaki() {
return jmlKaki;
}

public void setJmlKaki(int jmlKaki) {
this.jmlKaki = jmlKaki;
}

public abstract void displayBinatang();
}
31 changes: 31 additions & 0 deletions 1941720240_Addina Nurul Mawaddah/tugasinterface/Gorilla.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package tugasinterface;

public class Gorilla extends Binatang implements Karnivora, Herbivora{
private String suara;
private String warnaBulu;

public Gorilla(String suara, String warnaBulu, String nama, int jmlKaki) {
super(nama, jmlKaki);
this.suara = suara;
this.warnaBulu = warnaBulu;
}

@Override
public void displayMakan() {
System.out.println("Jenis : Karnivora + Herbivora");
System.out.println("Makanan : Daging + Tumbuhan");
}

@Override
public void displayBinatang(){
System.out.println("Nama : " + this.nama);
System.out.println("Jumlah Kaki : " + this.jmlKaki);
}

public void diplayData(){
System.out.println("Suara : " + this.suara);
System.out.println("Warna Bulu : " + this.warnaBulu);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package tugasinterface;

public interface Herbivora {
public abstract void displayMakan();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package tugasinterface;

public interface Karnivora {
public abstract void displayMakan();
}
30 changes: 30 additions & 0 deletions 1941720240_Addina Nurul Mawaddah/tugasinterface/Keledai.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package tugasinterface;

public class Keledai extends Binatang implements Herbivora{
private String suara;
private String warnaBulu;

public Keledai(String suara, String warnaBulu, String nama, int jmlKaki) {
super(nama, jmlKaki);
this.suara = suara;
this.warnaBulu = warnaBulu;
}

@Override
public void displayMakan() {
System.out.println("Jenis : Herbivora");
System.out.println("Makanan : Tumbuhan");
}

@Override
public void displayBinatang(){
System.out.println("Nama : " + this.nama);
System.out.println("Jumlah Kaki : " + this.jmlKaki);
}

public void diplayData(){
System.out.println("Suara : " + this.suara);
System.out.println("Warna Bulu : " + this.warnaBulu);
}

}
24 changes: 24 additions & 0 deletions 1941720240_Addina Nurul Mawaddah/tugasinterface/Mainbinatang.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package tugasinterface;

public class Mainbinatang {
public static void main(String[] args) {
Keledai kl = new Keledai("hehehehe", "Abu-abu", "Keledai", 4);
Gorilla gl = new Gorilla("haaum hauumm", "Hitam Manis", "Gorilla", 4);
Singa sg = new Singa("Roarrr roarrr", "Coklat", "Singa", 4);

kl.displayMakan();
kl.displayBinatang();
kl.diplayData();
System.out.println("");

gl.displayMakan();
gl.displayBinatang();
gl.diplayData();
System.out.println("");

sg.displayMakan();
sg.displayBinatang();
sg.diplayData();

}
}
30 changes: 30 additions & 0 deletions 1941720240_Addina Nurul Mawaddah/tugasinterface/Singa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package tugasinterface;

public class Singa extends Binatang implements Karnivora{
private String suara;
private String warnaBulu;

public Singa(String suara, String warnaBulu, String nama, int jmlKaki) {
super(nama, jmlKaki);
this.suara = suara;
this.warnaBulu = warnaBulu;
}

@Override
public void displayMakan() {
System.out.println("Jenis : Karnivora");
System.out.println("Makanan : Daging");
}

@Override
public void displayBinatang(){
System.out.println("Nama : " + this.nama);
System.out.println("Jumlah Kaki : " + this.jmlKaki);
}

public void diplayData(){
System.out.println("Suara : " + this.suara);
System.out.println("Warna Bulu : " + this.warnaBulu);
}

}