Code:
- Class Interface Moveable:
public interface Moveable
{
public void Jump();
public void Forward();
}
- Class abstract Actor:
public abstract class Actor implements Moveable
{
private Circle face;
public Actor(){
face = new Circle();
face.makeVisible();
face.changeColor("red");
face.changeSize(50);
}
public void Jump(){
face.slowMoveVertical(-30);
}
public void Forward(){
face.slowMoveHorizontal(10);
}
}
- Class extend GoJumpActor:
public class GoJumpActor extends Actor
{
public void GoAndJump(){
Forward();
Jump();
}
}
- Class extend JumpGoActor:
public class JumpGoActor extends Actor
{
public void JumpAndGo(){
Jump();
Forward();
}
}
Không có nhận xét nào:
Đăng nhận xét