Select Git revision
personListing.jsx
-
Jean-Christophe authoredJean-Christophe authored
Input.java 1.45 KiB
package bitFight;
import java.io.IOException;
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) {
do {
try {
setInput(input);
} catch (InvalidInputException e) {
try {
Display.newPrintln(e.getMessage());
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
while (!validInput());
}
public Input() {
this.inputRange = new ArrayList<>();
this.inputRange.add("q"); //Commande pour quitter
this.inputRange.add("a"); //Commande pour attaquer
for (Attack a : Attack.values()) this.inputRange.add(a.getName());
for (Defense d : Defense.values()) this.inputRange.add(d.getName());
}
public boolean validInput() {
boolean valid = false;
for(String s : inputRange) if (s.equals(input)) valid = true;
return valid;
}
}