Select Git revision
Forked from an inaccessible project.
-
Leonard Corre authoredLeonard Corre authored
Input.java 1.34 KiB
package bitFight;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Input {
private String input = "";
private ArrayList<String> inputRange;
public String getInput() {
return input;
}
public ArrayList<String> getInputRange() {
return inputRange;
}
public void setInput(String input) throws InvalidInputException {
this.input = input;
if (!validInput()) {
throw new InvalidInputException(getInputRange().toString());
}
System.out.println(input);
}
public void newInput(String input) {
while (!validInput()) {
try {
setInput(input);
} catch (InvalidInputException e) {
try {
Display.newPrintln(e.getMessage());
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
public Input() {
this.inputRange = new ArrayList<>();
this.inputRange.add("q"); //Commande pour quitter
this.inputRange.add("a"); //Commande pour attaquer
}
public boolean validInput() {
boolean valid = false;
for(String s : inputRange) if (s.equals(input)) valid = true;
return valid;
}
}