Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean move(Direction direction)
- {
- int newPosition = direction.getNextPosition(this);
- MovedEmptySlot emptySlot = new MovedEmptySlot(emptySlotPos, newPosition);
- if (newPosition < 0) {
- return false;
- }
- else {
- arrayID[emptySlotPos] = newPosition;
- arrayID[newPosition] = -1;
- emptySlotPos = arrayID[newPosition];
- movesPerformed.push(direction);
- this.notifyObservers(emptySlot);
- return true;
- }
- }
Add Comment
Please, Sign In to add comment