Rabu, 11 November 2009
di
20.29
|
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)
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
0 komentar:
Posting Komentar