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_1941720014_AulaFaridatuzZahro' #13

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
36 changes: 36 additions & 0 deletions interfacelatihan/Binatang.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
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 void displayBinatang() {

}
}
38 changes: 38 additions & 0 deletions interfacelatihan/Gorilla.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public class Gorilla extends Binatang implements IKarnivora, IHerbivora {

private String suara;
private String warnaBulu;

public Gorilla(String nama, int jmlKaki, String suara, String warnaBulu) {
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 : " + nama);
System.out.println("Jumlah Kaki : " + jmlKaki);
System.out.println("Suara : " + suara);
System.out.println("Warna Bulu : " + warnaBulu);
}

public void displayData() {
displayMakan();
displayBinatang();
System.out.println();
}

}
12 changes: 12 additions & 0 deletions interfacelatihan/IBerprestasi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public interface IBerprestasi {

abstract void menjuaraiKompetisi();

public abstract void membuatPublikasiilmiah();
}
12 changes: 12 additions & 0 deletions interfacelatihan/ICumlaude.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public interface ICumlaude {

public abstract void lulus();

public abstract void meraihIPKTinggi();
}
10 changes: 10 additions & 0 deletions interfacelatihan/IHerbivora.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public interface IHerbivora {

public void displayMakan();
}
10 changes: 10 additions & 0 deletions interfacelatihan/IKarnivora.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public interface IKarnivora {

public void displayMakan();
}
38 changes: 38 additions & 0 deletions interfacelatihan/Keledai.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public class Keledai extends Binatang implements IHerbivora {

private String suara;
private String warnaBulu;

public Keledai(String nama, int jmlKaki, String suara, String warnaBulu) {
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 : " + nama);
System.out.println("Jumlah Kaki : " + jmlKaki);
System.out.println("Suara : " + suara);
System.out.println("Warna Bulu : " + warnaBulu);
}

public void displayData() {
displayMakan();
displayBinatang();
System.out.println();
}

}
19 changes: 19 additions & 0 deletions interfacelatihan/Mahasiswa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
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 di kampus.");
}
}
18 changes: 18 additions & 0 deletions interfacelatihan/MainBinatang.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public class MainBinatang {

public static void main(String[] args) {
Keledai k = new Keledai("Kedelai", 4, "Hehehehe", "Abu-Abu");
Gorilla g = new Gorilla("Gulali", 4, "Haaum Hauum", "Hitam Manis");
Singa s = new Singa("CingaCing", 4, "Roaar Roaaar", "Coklat");

k.displayData();
g.displayData();
s.displayData();
}
}
24 changes: 24 additions & 0 deletions interfacelatihan/MultipleInterfaceMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public class MultipleInterfaceMain {

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

Sarjana sarjanaCum = new Sarjana("Dini");
PascaSarjana masterCum = new PascaSarjana("Elok");

pakRektor.beriSertifikatMawapres(sarjanaCum);
sarjanaCum.menjuaraiKompetisi();
sarjanaCum.membuatPublikasiilmiah();
System.out.println("--------------------------------------------");
pakRektor.beriSertifikatMawapres(masterCum);
masterCum.menjuaraiKompetisi();
masterCum.membuatPublikasiilmiah();
System.out.println("--------------------------------------------");
}
}
33 changes: 33 additions & 0 deletions interfacelatihan/PascaSarjana.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
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("Saya telah menjuarai kompetisi INTERNASIONAL");
}

@Override
public void membuatPublikasiilmiah() {
System.out.println("Saya menerbitkan artikel di jurnal INTERNASIONAL");
}

}
26 changes: 26 additions & 0 deletions interfacelatihan/Rektor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public class Rektor {

public void beriSertifikatCumlaude(ICumlaude mahasiswa) {
System.out.println("Saya REKTOR, memberikan sertifikat cumlaude.");
System.out.println("Selamat! Silakan memperkenalkan diri Anda...");

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

public void beriSertifikatMawapres(IBerprestasi mahasiswa) {
System.out.println("Saya REKTOR, memberikan sertifikat MAWAPRES.");
System.out.println("Selamat! Bagaimana Anda bisa berprestasi?");

// mahasiswa.menjuaraiKompetisi();
// mahasiswa.membuatPublikasiilmiah();
// System.out.println("--------------------------------------------");
}
}
33 changes: 33 additions & 0 deletions interfacelatihan/Sarjana.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public class Sarjana extends Mahasiswa implements ICumlaude, IBerprestasi {

public Sarjana(String nama) {
super(nama);
}

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

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

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

@Override
public void membuatPublikasiilmiah() {
System.out.println("Saya menerbitkan artikel di jurnal NASIONAL.");
}

}
38 changes: 38 additions & 0 deletions interfacelatihan/Singa.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package interfacelatihan;

/**
*
* @author Aulafz
*/
public class Singa extends Binatang implements IKarnivora {

private String suara;
private String warnaBulu;

public Singa(String nama, int jmlKaki, String suara, String warnaBulu) {
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 : " + nama);
System.out.println("Jumlah Kaki : " + jmlKaki);
System.out.println("Suara : " + suara);
System.out.println("Warna Bulu : " + warnaBulu);
}

public void displayData() {
displayMakan();
displayBinatang();
System.out.println();
}

}
34 changes: 34 additions & 0 deletions interfacelatihan/interfacemain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package interfacelatihan;

import interfacelatihan.ICumlaude;
import interfacelatihan.Mahasiswa;
import interfacelatihan.PascaSarjana;
import interfacelatihan.Rektor;
import interfacelatihan.Sarjana;

/**
*
* @author Aulafz
*/
public class interfacemain {

public static void main(String[] args) {
Rektor pakrektor = new Rektor();

Mahasiswa mhsBiasa = new Mahasiswa("Charlie");
Sarjana sarjanaCumlaude = new Sarjana("Dini");
PascaSarjana masterCumlaude = new PascaSarjana("Elok");

// pakrektor.beriSertifikatCumlaude((ICumlaude) mhsBiasa);
pakrektor.beriSertifikatCumlaude(sarjanaCumlaude);
sarjanaCumlaude.kuliahDiKampus();
sarjanaCumlaude.lulus();
sarjanaCumlaude.meraihIPKTinggi();
System.out.println("--------------------------------------------");
pakrektor.beriSertifikatCumlaude(masterCumlaude);
masterCumlaude.kuliahDiKampus();
masterCumlaude.lulus();
masterCumlaude.meraihIPKTinggi();
System.out.println("--------------------------------------------");
}
}