Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean push(Direction dir) {
- if((!dir.equals(Direction.EAST))&&(!dir.equals(Direction.WEST))){
- return false;
- }
- Position curPos = owner.getPosition(this);
- Position nextPos = curPos.moveDirection(dir);
- // If next position has an object not equal to empty the rock cant move
- IBDObject nextObject = owner.get(nextPos);
- if (nextObject instanceof BDEmpty&&owner.canGo(nextPos)) {
- try {
- prepareMove(nextPos.getX(), nextPos.getY());
- } catch (IllegalMoveException e) {
- return false;
- }
- owner.step();
- return true;
- }
- else{
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement