COMP204-08B Assignment 6

Build a Fifteen Puzzle

Due date: Monday, October 20, 5pm

What to submit:

One java file containing all you code.
Document your code well.
Use the javadoc @author tag to give your name and ID!

Specification:

Final position:

Some intermediate position:

Your task is to implement a very basic no-frills version of the Fifteen puzzle (if you do not know the Fifteen Puzzle, have a look here).

All that is needed is a field with 16 tiles: 15 ones numbered from 1 to 15, and a blank tile. Clicking on an active tile (one that can actually be slided) should move it and all tiles between it and the blank tile by one position. The tile clicked will become blank as a consequence of this move. Use the "final position" from above as the starting position.

Make sure that tiles are only "active", if they can actually be moved.

Assessment will be based on the following criteria:

  1. Functionality
  2. Reasonable clarity and style of programming.
  3. Reasonable documentation;

You may implement this puzzle using interface builders like the one included in NetBeans, if you want.

Full marks will be given for a correct no-frills version similar to the screenshots shown above.

Additionally, this assignment allows you to make up for lost marks in other assignments or tests: up to 5 bonus marks can be acquired for more polished versions of the game (e.g. fancier graphics, a way to save (and later reload) the current game, a display showing how many times the user has clicked/moved tiles, a generator for random but solvable starting positions, automatically detecting when the user solves the puzzle, etc.).

Here are a few hints:

  1. You can simply use 16 Buttons, and simulate moving tiles by just moving the buttons' labels/text around ...