Advanced Networking
Niit Project
Shuffle
FunKingdom, Inc. is a software development company that specializes in creating computer games. In a survey, the company found that many parents want their children to play computer games that will help them develop their logic. The development team has, therefore, decided to develop a game called Shuffle.
Rules of Shuffle
Shuffle is played as per the following rules:
n It is a single-player game.
n When the game starts, the application displays the name of the player who has completed the game in the minimum number of keystrokes. Then, it displays the numbers from zero to eight in random order in a 3×3 grid, as shown in the following figure.
n The objective of the game is to arrange the numbers in ascending order, as shown in the following arrangement.
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
0
|
n Zero indicates vacant space and therefore, it should come at the last.
n Numbers can be moved up, down, left, or right within the grid.
n The numbers can be moved by swapping them with the vacant space.
n Only one number can be moved at a time.
n Only the numbers adjacent to the vacant space in the same row or column can be swapped with the vacant space.
n A number cannot be moved diagonally.
n There is no time limit for the game. However, the number of key presses required to complete the game should be counted.
Design Specifications
The design of the game should be as per the following specifications:
n It is a single-player game.
n There is no time limit for completing the game.
n The numbers that initially appear on the screen should be shuffled each time a new game is started.
n Zero indicates a vacant place.
n The player can swap a number that is adjacent to zero. This number should be in the same row or column as zero.
n The vacant place, zero, can be moved left, right, up, or down.
n A player can swap a number with zero by pressing the following keys:
l L or l: Swaps 0 with the number on its left.
l L or l: Swaps 0 with the number on its left.
l R or r: Swaps 0 with the number on its right.
l U or u: Swaps 0 with the number above.
l D or d: Swaps 0 with the number below.
n After arranging all the numbers in ascending order, the player will press E or e on the keyboard to end the game.
n When the player presses E or e, the program will check whether the player has arranged the numbers correctly and display a message accordingly.
n The number of keystrokes to complete the game should be counted. If the count is less than the record count, the player should be asked to enter his/her name. The name of the player and the number of keystrokes should be saved in a file as the new record. This name and the number of keystrokes should appear on the screen when a player starts a new game.
DOWNLOAD from here:
https://drive.google.com/file/d/0BzDgK7VFVLaKZEFHdFBld0JQX00/edit?usp=sharing