tugas Asisten Post....buat main nya....
kalo bisa buat sebuah cerita tentang implementasi nya....
ok?
have a nice day............
package operator;
interface InterfaceState
{
public static final boolean ON_state = true;
public static final boolean OFF_state = false;
public abstract void ON();
public abstract void OFF();
}
interface InterfaceAddPos extends InterfaceState
{
public static final int Max = 1000;
public static final int Min = 0;
public abstract void subtract();
public abstract void add();
}
public class AddPos implements InterfaceAddPos
{
private boolean state = false;
private int position = 0;
public void ON()
{
this.state = ON_state;
System.out.println("ON State : " + this.state + " Position : " + this.position);
}
public void OFF()
{
this.state = OFF_state;
System.out.println("OFF State : " + this.state + " Position : " + this.position);
}
public void subtract()
{
if(this.state && this.position!=Min){
this.position--;
if(this.position==Min) this.state = OFF_state;
}
System.out.println("--- State : " + this.state + " Position : " + this.position);
}
public void add()
{
if(this.state && this.position!=Max){
this.position++;
}
System.out.println("+++ State : " + this.state + " Position : " + this.position);
}
}
Tidak ada komentar:
Posting Komentar