COMP 110-001: Introduction to Programming, SSI'15

Lab 8

25 points

Assigned: Thursday, June 11, 2015
Due: Monday, June 15, 2015 by 11:59pm (EDT)

Description

15-Tile Puzzle - Part 2

The 15-Tile Puzzle is a game where a player moves tiles on a 4 x 4 board to try to arrange them into a predetermined order. You are to do a simulation of this game in lab 7-8.

 
+---+---+---+---+
| 1 | 2 | 3 | 4 |
+---+---+---+---+
| 5 | 6 | 7 | 8 |
+---+---+---+---+
| 9 |10 |11 |12 |
+---+---+---+---+
|13 |14 |15 |   |
+---+---+---+---+

In lab 7, you have implemented the main game that supports the following commands:

'R': Moves a tile to the right
'L': Moves a tile to the left
'U': Moves a tile up
'D': Moves a tile down
'Q': Quit the program

In this lab, you will implement another two functions:

'S': Save the current board
'O': Load the saved board

The save function will save the current board information into a text file. The file can be of any name in any location of your choice. You also need to decide the saved format (e.g., one number per line).

The load function will load the saved board information, which allows a user to continue to play the game from the saved one.

You also need to handle FileNotFoundException when saving and loading the game.

Grading

How to turn in the assignment

Let me know if you encounter any problems in this lab.