INNER ABSTRACK

package inner_abstrak;
abstract class Kendaraan{
protected String nama;
protected int jumRoda;
protected boolean bisaMundur = false;

public Kendaraan(String nama, int roda, boolean mundur){
this.nama = nama;
this.jumRoda = roda;
this.bisaMundur = mundur;
}
public abstract void bersuara();
public static void bunyi(){
System.out.println("Nyam.....Nyam");
}
public void isKendaraan(){
System.out.println("Nama : "+ nama);
System.out.println("Jumlah Roda : "+ jumRoda);
System.out.println("Bisa Mundur : "+ bisaMundur);
}
}

interface Manusia{
public void bicara();
public void berkelahi();
}

class Mobil extends Kendaraan{
public Mobil(){
super("Mobil",4,true);
}
public void bersuara(){
System.out.println("\nMbrem...mbrem...");
}
}

class Motor extends Kendaraan{
public Motor(){
super("Motor",2,false);
}
public void bersuara(){
System.out.println("\nNgeeeng...ngeeeeng");
}
}

class Bumblebee extends Kendaraan implements Manusia{
public Bumblebee(){
super("Bumblebee",4,true);
}
public void bersuara(){
System.out.println("\nEhem...Woooouuu");
}
public void berkelahi(){
System.out.println("\nGedebruk..Gedubrak");
}
public void bicara(){
System.out.println("\nHeellloooo...!!!");
}
public static void main(String[] args) {
Mobil mb = new Mobil();
mb.isKendaraan();
mb.bersuara();
Motor mt = new Motor();
mt.isKendaraan();
mt.bersuara();
Bumblebee b = new Bumblebee();
b.isKendaraan();
b.bersuara();
b.bicara();
b.berkelahi();
}
}



OUTPUT :
run:
Nama : Mobil
Jumlah Roda : 4
Bisa Mundur : true

Mbrem...mbrem...
Nama : Motor
Jumlah Roda : 2
Bisa Mundur : false

Ngeeeng...ngeeeeng
Nama : Bumblebee
Jumlah Roda : 4
Bisa Mundur : true

Ehem...Woooouuu

Heellloooo...!!!

Gedebruk..Gedubrak
BUILD SUCCESSFUL (total time: 2 seconds)
Diposting oleh UntarA pRatama
Visit the Site
MARVEL and SPIDER-MAN: TM & 2007 Marvel Characters, Inc. Motion Picture © 2007 Columbia Pictures Industries, Inc. All Rights Reserved. 2007 Sony Pictures Digital Inc. All rights reserved. blogger templates