P
perpetuallyfrozen
I am having some problems with the following lines of code:
/** Gets a move entered thru console and returns it.
* @param input the move entered by user
* @return returns a valid move entered by user
*/
private String getMove() {
BufferedReader console =
new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a move: ");
String input = console.readLine();
if (!checkMove(input)) {
System.out.println("Not a valid move.");
input = getMove();
}
return input;
}
I have no idea why this code isn't working. Do I have to import
java.io or something? The method is simply supposed to retrieve a
string from the console and return it. What am I doing wrong?
Suggestions?? Thanks in advance for any replies.
- Chris
p.s. checkMove() checks the move to a list of valid moves and returns
a boolean
/** Gets a move entered thru console and returns it.
* @param input the move entered by user
* @return returns a valid move entered by user
*/
private String getMove() {
BufferedReader console =
new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a move: ");
String input = console.readLine();
if (!checkMove(input)) {
System.out.println("Not a valid move.");
input = getMove();
}
return input;
}
I have no idea why this code isn't working. Do I have to import
java.io or something? The method is simply supposed to retrieve a
string from the console and return it. What am I doing wrong?
Suggestions?? Thanks in advance for any replies.
- Chris
p.s. checkMove() checks the move to a list of valid moves and returns
a boolean