Assignment Write a web page that enables the user to play the game of 15. There is a 4-by-4 board (implemented as an HTML table) for a total of 16 slots. One of the slots is empty. The other slots are occupied by 15 tiles, randomly numbered from 1 through 15. Any tile next to the currently empty slot can be moved into the currently empty slot by clicking on the tile. Requirements
- Your program should create a board with the tiles out of order. The user’s goal is to arrange the tiles in sequential order row by row. Using the DOM and the onclick event, write a script that allows the user to swap the positions of the open position and an adjacent tile. [Hint: The onclick event should be specified for each table cell.]
- Your program should determine when the game is over, and then prompt the user to determine whether to play again. If so, scramble the numbers using the Math.random method.
- Your program should allow a user quit the current game and start a new game (create a “New Game” button for it).
-
- Your program should allow a user create a simple game with only one tire out of position so that a user can solve the puzzle with one move (create a “Simple Game” button for it).
-
- Your program should count the number of moves a user has already made in the current game.
-
- Your program should record the amount of time a user has already spent on the current game.
-
- Your program must work in both Internet Explorer and Google Chrome.
-
- Your program must be written in JavaScript. You are not allowed to use any JavaScript library such as jQuery.