Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package commands;
- import entities.Hero;
- import entities.Hero.Direction;
- public class MoveCommand implements Command {
- private Hero hero;
- private Direction direction;
- public MoveCommand(Hero h, Direction dir) {
- // TODO Auto-generated constructor stub
- hero = h;
- direction = dir;
- }
- @Override
- public void undo() {
- // TODO Auto-generated method stub
- switch (direction) {
- case E:
- hero.move(Direction.W);
- case W:
- hero.move(Direction.E);
- case N:
- hero.move(Direction.S);
- case S:
- hero.move(Direction.N);
- default:
- break;
- }
- }
- @Override
- public void execute() {
- // TODO Auto-generated method stub
- hero.move(direction);
- }
- // TODO implement the move command
- /* - MoveCommand(Hero, Direction)
- - void undo()
- - void execute()
- - maybe helper method for undo ?
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement