Several new methods added in Parser class

This commit is contained in:
Leonardo Brandenberger
2021-12-02 15:15:39 +01:00
parent 9e347e8792
commit 3c67d62e42
4 changed files with 39 additions and 20 deletions
-3
View File
@@ -8,9 +8,6 @@ public enum Command {
private String commandWord;
public static <T extends Enum<T>> T getEnumValue(TextIO textIO, Class<T> commands) {
return textIO.newEnumInputReader(commands).read("What would you like to do?");
}
Command(String commandWord) {
+36 -16
View File
@@ -3,34 +3,54 @@ import org.beryx.textio.TextIO;
import org.beryx.textio.TextIoFactory;
import org.beryx.textio.TextTerminal;
import java.awt.*;
import static ch.zhaw.catan.Command.QUIT;
import static ch.zhaw.catan.Command.UNKNOWN;
public class Parser {
TextIO textIO = TextIoFactory.getTextIO();
TextTerminal<?> textTerminal;
public Parser() {
textTerminal = textIO.getTextTerminal();
run();
}
public Point getPoint() {
return null;
}
public void run() {
boolean running = true;
while (running) {
switch(Command.getEnumValue(textIO, Command.class)){
case QUIT:
running = false;
break;
case UNKNOWN:
break;
public int gameStart(){
return 2;
}
public void giveCoordinatesForStructures(Config.Structure structure) {
}
}
public void thrownDices(int number){
}
public void playerTurn(Config.Faction faction) {
}
public void errorMessage(){
}
public Command getAction() {
switch (textIO.newEnumInputReader(Command.class).read("What would you like to do?")) {
case QUIT:
System.out.println("quit");
return QUIT;
case UNKNOWN:
return UNKNOWN;
default:
return null;
}
}
}
+2
View File
@@ -15,6 +15,8 @@ public class Siedler {
TextIO textIO = TextIoFactory.getTextIO();
TextTerminal<?> textTerminal = textIO.getTextTerminal();
textTerminal.println(game.getBoard().getTextView());
Parser parser = new Parser();
parser.getAction();