import java.util.Scanner;

/**
 * A console application that plays the Game of Fifteen.
 *
 * @author Drue Coles
 */
public class ConsoleFifteen {

    public static void main(String[] args) {
        Fifteen game = new Fifteen();
        System.out.println("\n***********************");
        System.out.println("*** Game of Fifteen ***");
        System.out.println("***********************\n");

        Scanner in = new Scanner(System.in);

        while (!game.over()) {
            System.out.println(game);
            System.out.print("Tile to move (0 to quit): ");
            int tile = in.nextInt();
            System.out.println();
            if (tile == 0) {
                break;
            }
            game.slide(tile);
        }

        if (game.over()) {
            System.out.println("YOU HAVE SOLVED THE PUZZLE!");
        } else {
            System.out.println("QUITTER!");
        }
    }
}