Tumbuhan.java
abstract class tumbuhan{
protected String nama;
protected boolean makanSerangga = false;
protected boolean insektivora = false;
public tumbuhan(String nama,boolean makanSerangga,boolean insektivora){
this.nama = nama;
this.makanSerangga = makanSerangga;
this.insektivora = insektivora;
}
public abstract void makan();
public static void jenis(){
System.out.println("makan sayur dan buah");
}
public void tumbuhan( ){
System.out.println("\nNama : "+nama);
System.out.println("Makan Serangga : "+makanSerangga);
System.out.println("insektivora : "+insektivora);
}
}
Hewan.java
abstract class hewan{
protected String nama;
protected boolean makanTumbuhan = false;
protected boolean makanHewan = false;
protected boolean herbivora = false;
protected boolean karnivora = false;
public hewan(String nama,boolean makanTumbuhan,boolean makanHewan,boolean herbivora,boolean karnivora){
this.nama = nama;
this.makanTumbuhan = makanTumbuhan;
this.makanHewan = makanHewan;
this.herbivora = herbivora;
this.karnivora = karnivora;
}
public abstract void makan();
public static void jenis(){
System.out.println("makan daging, ayam ");
}
public void hewan( ){
System.out.println(" ");
System.out.println("Nama : "+nama);
System.out.println("Makan Tumbuhan : "+makanTumbuhan);
System.out.println("Makan Hewan : "+makanHewan);
System.out.println("Herbivora : "+herbivora);
System.out.println("karnivora : "+karnivora);
}
}
Manusia.java
interface manusia {
public void makan();
public void tipe();
}
Kucing.java
class kucing extends hewan{
public kucing(){
super("Kucing",false,true,false,true);
}
public void makan(){
System.out.println("\n mmeeeeeeeeooooooong\n");
}
public static void main(String[]args){
kucing s = new kucing();
s.hewan();
s.makan();
}
}
Kelinci.java
class kelinci extends hewan{
public kelinci(){
super("Kelinci",true,false,true,false);
}
public void makan(){
System.out.println("\n ciit...ciittt\n");
}
public static void main(String[]args){
kelinci j = new kelinci();
j.hewan();
j.makan();
}
}
Kantongsemar.java
class kantongsemar extends tumbuhan{
public kantongsemar(){
super("Kantong Semar",true,true);
}
public void makan(){
System.out.println("\n haaaaaaap\n");
}
public static void main(String[]args){
kantongsemar ks = new kantongsemar();
ks.tumbuhan();
ks.makan();
}
}
Superman.java
class batman extends hewan implements manusia{
public batman(){
super("Batman",true,true,true,true);
}
public void makan(){
System.out.println("\n nyam..nyam..nyam.. \n");
}
public void jenis1(){
super.jenis();
}
public void tipe(){
System.out.println("\n semua dimakan..pasti omnivora\n");
}
public static void rasa(){
System.out.println("\n enaaaaaaakkkk\n");
}
public static void main(String[]args){
batman s = new batman();
s.hewan();
s.makan();
s.jenis1();
tumbuhan.jenis();
s.tipe();
rasa();
}
}