Write the Java code to faithfully implement your design, following the Java Naming Convention and proper formatting styles. Fully test and debug the program.

REVISION

The 9-puzzle (also knosut as the 8-puzzle) is a sliding puzzle that consists of eight squares labeled 1 to 8 on a 3 x 3 grid with one empty space. The following figures show some examples of grid configurations. Each move slides one neighboring square into the empty space. For example, the first two figures below show one move that slides the square “4” into the empty space. The goal of the puzzle is to reach the configuration on the right by making a series of moves.

Implement the 9-puzzle in Java that displays the grid and responds to the user’s moves.
Use a 2D array to represent the grid. Repeatedly print the current grid configuration on the console and prompt the user to enter a move (a number I 8 indicating the neighboring square to slide into the empty space). Any invalid user input should be ignored. The program terminates when the user enters the number 0.

Analyze the 9-puzzle problem and identify self-contained smaller functions. Design a modular solution to the problem using the principles of method abstraction, divide-and-conquer and incremental development.

Write the Java code to faithfully implement your design, following the Java Naming Convention and proper formatting styles. Fully test and debug the program.