@@ -0,0 +1,2058 @@
+package theknightstour;%0A%0Aimport java.awt.Point;%0Aimport java.util.Scanner;%0A%0Apublic class KnightsTourCLI%0A%7B%0A  private KnightsTour knightsTour;%0A%0A  public KnightsTourCLI(int rows, int columns, int startX, int startY)%0A  %7B%0A    knightsTour = new KnightsTour(rows, columns, startX, startY);%0A%0A    Scanner scanner = new Scanner(System.in);%0A    char choice;%0A%0A    boolean running = true;%0A    do%0A    %7B%0A      printBoard();%0A%0A      String input = scanner.nextLine();%0A      for (int i = 0; i %3C input.length(); i++)%0A      %7B%0A        choice = input.charAt(i);%0A%0A        switch (choice)%0A        %7B%0A          case 'n':%0A            knightsTour.step();%0A            break;%0A          case 'q':%0A            running = false;%0A            break;%0A          default:%0A            System.out.println(%22n = Step, q = Quit%22);%0A        %7D%0A      %7D%0A    %7D%0A    while (running);%0A  %7D%0A%0A  private void printBoard()%0A  %7B%0A    if (knightsTour != null)%0A    %7B%0A      boolean%5B%5D%5B%5D board = knightsTour.getBoard();%0A%0A      int rows = knightsTour.getRows(),%0A          columns = knightsTour.getColumns();%0A%0A      Point knight = knightsTour.getKnight();%0A%0A      for (int y = 0; y %3C rows; y++)%0A      %7B%0A        for (int x = 0; x %3C columns; x++)%0A        %7B%0A          if (x == knight.x && y == knight.y)%0A            System.out.print(%22$%22);%0A          else%0A            System.out.print(board%5By%5D%5Bx%5D ? %22#%22 : %22-%22);%0A        %7D%0A%0A        System.out.println(%22%22);%0A      %7D%0A    %7D%0A  %7D%0A%0A  public static void main(String%5B%5D args)%0A  %7B%0A    if (args.length %3E 3)%0A    %7B%0A      try%0A      %7B%0A        int rows = Integer.parseInt(args%5B0%5D),%0A            columns = Integer.parseInt(args%5B1%5D),%0A            startX = Integer.parseInt(args%5B2%5D),%0A            startY = Integer.parseInt(args%5B3%5D);%0A%0A        KnightsTourCLI cli = new KnightsTourCLI(rows, columns, startX, startY);%0A      %7D%0A      catch (NumberFormatException e)%0A      %7B%0A        System.err.println(e.getMessage());%0A        e.printStackTrace();%0A      %7D%0A    %7D%0A    else%0A    %7B%0A      System.out.println(%22Usage:%22);%0A      System.out.println(%22java theknightstour.KnightsTourCLI ROWS COLUMS STARTX STARTY%22);%0A    %7D%0A  %7D%0A%7D%0A

Implement simple CLI