diff --git a/.gitignore b/.gitignore index 6a3417b..ed8c940 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore index 73f69e0..2367661 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -6,3 +6,5 @@ /dataSources.local.xml # Editor-based HTTP Client requests /httpRequests/ +/misc.xml +/out/ \ No newline at end of file diff --git a/src/ch/zhaw/catan/Command.java b/src/ch/zhaw/catan/Command.java index 013698e..6abf2b5 100644 --- a/src/ch/zhaw/catan/Command.java +++ b/src/ch/zhaw/catan/Command.java @@ -1,11 +1,22 @@ package ch.zhaw.catan; -public enum Command { - NEXTPLAYER ("next Player"), QUIT("quit"); +import org.beryx.textio.TextIO; + +public enum Command { + NEXTPLAYER ("next Player"), QUIT("quit"), UNKNOWN ("unknown"); + + private String commandWord; + + + public static > T getEnumValue(TextIO textIO, Class 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; } } diff --git a/src/ch/zhaw/catan/Parser.java b/src/ch/zhaw/catan/Parser.java index 15a4cd0..b131458 100644 --- a/src/ch/zhaw/catan/Parser.java +++ b/src/ch/zhaw/catan/Parser.java @@ -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; + + + } + } } diff --git a/src/ch/zhaw/catan/Siedler.java b/src/ch/zhaw/catan/Siedler.java index 5d5deb6..8f62515 100644 --- a/src/ch/zhaw/catan/Siedler.java +++ b/src/ch/zhaw/catan/Siedler.java @@ -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) {