Guest User

Untitled

a guest
May 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. public boolean move(Direction direction)
  2. {
  3. int newPosition = direction.getNextPosition(this);
  4. MovedEmptySlot emptySlot = new MovedEmptySlot(emptySlotPos, newPosition);
  5. if (newPosition < 0) {
  6. return false;
  7. }
  8. else {
  9. arrayID[emptySlotPos] = newPosition;
  10. arrayID[newPosition] = -1;
  11. emptySlotPos = arrayID[newPosition];
  12. movesPerformed.push(direction);
  13. this.notifyObservers(emptySlot);
  14. return true;
  15. }
  16. }
Add Comment
Please, Sign In to add comment