public static int getInput(Robot r) throws IOException { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char in = (char) br.readLine().toCharArray()[0]; if (in == 'N') { return 1; } if (in == 'M') { return 2; } r.moveRobot(in); } catch (Exception e) { System.out.println("input something"); return -1; } return 0; }