The program does not have an input check at the early phase. A wrong input will lead to program crash. To avoid this, a input check statement is added. The implementation is as follows: Former partial code: System.out.println("Please input start move"); int start_x = 0; int start_y = 0; if (in.hasNextInt()) { start_x = in.nextInt(); start_y = in.nextInt(); } Point ps = new Point(start_x, start_y); StartMove start_m = new StartMove(ps); New partial code: System.out.println("Please input start move"); int start_x = 0; int start_y = 0; // if start_x or start_y is out of range [0,8] do { if (in.hasNextInt()) { start_x = in.nextInt(); start_y = in.nextInt(); } } while (start_x < 0 || start_x > 8 || start_y < 0 || start_y > 8); Point ps = Graph.getInstance().chessboard[start_x][start_y];