Robot Program With Java

interface Robot

{
public void kedepan ();
public void kesamping ();
public void lompat ();
}

class Robota implements Robot
{
public Robota() {}
public void kedepan()
{
System.out.println (”Robot A bergerak kedepan dengan cepat”);
}
public void kesamping()
{
System.out.println (”Robot A bergerak kesamping dengan lambat”);
}
public void lompat()
{
System.out.println (”Robot A melompat dengan lambat”);
}
}

class Robotb implements Robot
{
public Robotb() {}
public void kedepan()
{
System.out.println (”Robot B bergerak kedepan dengan lambat”);
}
public void kesamping()
{
System.out.println (”Robot B bergerak kesamping dengan cepat”);
}
public void lompat()
{
System.out.println (”Robot B melompat dengan kecepatan sedang”);
}
public void terbang()
{
System.out.println (”Robot B terbang melayang diudara”);
}
}
class Robotc implements Robot
{
public Robotc() {}
public void kedepan()
{
System.out.println (”Robot C bergerak kedepan dengan lambat”);
}
public void kesamping()
{
System.out.println (”Robot C bergerak kesamping dengan cepat”);
}
public void lompat()
{
System.out.println (”Robot C melompat dengan kecepatan sedang”);
}
public void diam ()
{
System.out.println (”Robot C diam”);
}
}

public class Gerak
{
private Robota wRobota;
private Robotb wRobotb;
private Robotc wRobotc;

public Gerak()
{
wRobota = new Robota();
wRobotb = new Robotb();
wRobotc = new Robotc();
}

private void outputRobota()
{
wRobota.kedepan();
wRobota.kesamping();
wRobota.lompat();
}

private void outputRobotb()
{
wRobotb.kedepan();
wRobotb.kesamping();
wRobotb.lompat();
wRobotb.terbang();
}

private void outputRobotc()
{
wRobotc.kedepan();
wRobotc.kesamping();
wRobotc.lompat();
wRobotc.diam();
}

public static void main(String[]args)
{
Gerak wGerak = new Gerak();
wGerak.outputRobota();
wGerak.outputRobotb();
wGerak.outputRobotc();
}

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: