implementing part of Parser class
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
package ch.zhaw.catan;
|
||||
|
||||
import org.beryx.textio.TextIO;
|
||||
|
||||
public enum Command {
|
||||
NEXTPLAYER ("next Player"), QUIT("quit");
|
||||
NEXTPLAYER ("next Player"), QUIT("quit"), UNKNOWN ("unknown");
|
||||
|
||||
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?");
|
||||
}
|
||||
|
||||
private String CommandWord;
|
||||
|
||||
Command(String commandWord) {
|
||||
this.CommandWord = commandWord;
|
||||
this.commandWord = commandWord;
|
||||
}
|
||||
public String toString() {
|
||||
return commandWord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public class Parser {
|
||||
TextTerminal<?> textTerminal;
|
||||
|
||||
|
||||
|
||||
public Parser() {
|
||||
textTerminal = textIO.getTextTerminal();
|
||||
run();
|
||||
@@ -16,6 +17,16 @@ public class Parser {
|
||||
public void run() {
|
||||
boolean running = true;
|
||||
while (running) {
|
||||
switch(Command.getEnumValue(textIO, Command.class)){
|
||||
case QUIT:
|
||||
running = false;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import org.beryx.textio.TextIO;
|
||||
import org.beryx.textio.TextIoFactory;
|
||||
import org.beryx.textio.TextTerminal;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Siedler {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user