I'm writing a text based game where movement is dictated by typing "go left," "go right," etc. I have a Boolean Array List with the valid commands, and I want to compare what the user types to the members in the array. The code I have rejects all commands as invalid. I believe it's because I'm returning false, but I'm not sure how to fix it. I'm very new to this, so any and all help is appreciated.
private boolean validCommand() {
ArrayList<Boolean> validCommand = new ArrayList<>();
validCommand.add(Boolean.valueOf("go left"));
validCommand.add(Boolean.valueOf("go right"));
validCommand.add(Boolean.valueOf("go straight"));
validCommand.add(Boolean.valueOf("go back"));
for (boolean checkCommand : validCommand) {
if (typeCommand.getText().toString().equals(checkCommand))
return true;
}
return false;
}
typeCommand is just the EditText the user types their command in.