implementing part of Parser class

This commit is contained in:
Leonardo Brandenberger 2021-12-01 23:24:16 +01:00
parent 3830cf6594
commit 9e347e8792
5 changed files with 104 additions and 7 deletions

77
.gitignore vendored
View File

@ -1 +1,76 @@
/out/ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
misc.xml
SiedlerBoard.class
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

2
.idea/.gitignore vendored
View File

@ -6,3 +6,5 @@
/dataSources.local.xml /dataSources.local.xml
# Editor-based HTTP Client requests # Editor-based HTTP Client requests
/httpRequests/ /httpRequests/
/misc.xml
/out/

View File

@ -1,11 +1,22 @@
package ch.zhaw.catan; package ch.zhaw.catan;
public enum Command { import org.beryx.textio.TextIO;
NEXTPLAYER ("next Player"), QUIT("quit");
public enum Command {
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) { Command(String commandWord) {
this.CommandWord = commandWord; this.commandWord = commandWord;
}
public String toString() {
return commandWord;
} }
} }

View File

@ -8,6 +8,7 @@ public class Parser {
TextTerminal<?> textTerminal; TextTerminal<?> textTerminal;
public Parser() { public Parser() {
textTerminal = textIO.getTextTerminal(); textTerminal = textIO.getTextTerminal();
run(); run();
@ -16,6 +17,16 @@ public class Parser {
public void run() { public void run() {
boolean running = true; boolean running = true;
while (running) { while (running) {
switch(Command.getEnumValue(textIO, Command.class)){
case QUIT:
running = false;
break;
case UNKNOWN:
break;
}
} }
} }

View File

@ -4,8 +4,6 @@ import org.beryx.textio.TextIO;
import org.beryx.textio.TextIoFactory; import org.beryx.textio.TextIoFactory;
import org.beryx.textio.TextTerminal; import org.beryx.textio.TextTerminal;
import java.awt.*;
public class Siedler { public class Siedler {
public static void main(String[] args) { public static void main(String[] args) {