Software is a big industry. One of its demands is rapid development and extensible capacity. Duplicated or “copy & paste” code seems good in software development, but in fact, it is the cause of many problems for:
- maintain due to order to find & fix every buggy repeated code
- understand because the code is larger
- etc.
As an architect and developer of your fantastic team, you need to figure out a framework of your game. (mark of 3)
Code:
//Moveable
public interface Moveable
{
void jump();
void forward();
}
// Actor
public abstract class Actor implements Moveable { private Circle player; public Actor() { player = new Circle(); player.makeVisible(); } public void jump() { player.slowMoveVertical(-100); player.slowMoveVertical(100); } public void forward() { player.slowMoveHorizontal(10); } }
public class JumpGoActor extends Actor { public void jump() { super.player.slowMoveVertical(-3); forward(); } }
// GoJumpActor
public class GoJumpActor extends Actor { public void jump() { forward(); super.player.slowMoveVertical(-3); } }
Make an explanation to your team about the need of this framework, also point out some of this advantages to demonstrate your awareness of the complexity of this framework.
Abstract: Khá giống so với Interface, giúp quản lí các method dễ dàng hơn.
- Có khả năng đặt public/private/protected cho các method
- Có thể thêm/sửa các lệnh trong abstract method
No comments:
Post a Comment