From 063178edad2757958c1e2b996ca745112881f6be Mon Sep 17 00:00:00 2001 From: cedri Date: Thu, 17 Nov 2022 11:43:33 +0100 Subject: [PATCH] =?UTF-8?q?Hauptmen=C3=BC=20und=20Struktur=20angelegt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UI/test.java | 5 -- src/domain/Spiel.java | 14 +++++ src/domain/test.java | 5 -- src/facade/Spielsystem.java | 17 ++++++ src/fascade/test.java | 5 -- .../Persistenz.java} | 4 +- src/infrastructure/test.java | 5 -- src/main/Main.java | 14 +++++ src/ui/UI.java | 60 +++++++++++++++++++ 9 files changed, 107 insertions(+), 22 deletions(-) delete mode 100644 src/UI/test.java create mode 100644 src/domain/Spiel.java delete mode 100644 src/domain/test.java create mode 100644 src/facade/Spielsystem.java delete mode 100644 src/fascade/test.java rename src/{main/main.java => infrastructure/Persistenz.java} (63%) delete mode 100644 src/infrastructure/test.java create mode 100644 src/main/Main.java create mode 100644 src/ui/UI.java diff --git a/src/UI/test.java b/src/UI/test.java deleted file mode 100644 index cabd839..0000000 --- a/src/UI/test.java +++ /dev/null @@ -1,5 +0,0 @@ -package UI; - -public class test { - //test -} diff --git a/src/domain/Spiel.java b/src/domain/Spiel.java new file mode 100644 index 0000000..4622cc7 --- /dev/null +++ b/src/domain/Spiel.java @@ -0,0 +1,14 @@ +package domain; + +public class Spiel { + private String spielname; + + public Spiel(String spielname) { + this.spielname = spielname; + } + + public String getSpielname() { + return spielname; + } + +} diff --git a/src/domain/test.java b/src/domain/test.java deleted file mode 100644 index 6069fd5..0000000 --- a/src/domain/test.java +++ /dev/null @@ -1,5 +0,0 @@ -package domain; - -public class test { - //test -} diff --git a/src/facade/Spielsystem.java b/src/facade/Spielsystem.java new file mode 100644 index 0000000..be6201c --- /dev/null +++ b/src/facade/Spielsystem.java @@ -0,0 +1,17 @@ +package facade; + +import domain.Spiel; + +public class Spielsystem { + private Spiel spiel; + + public Spielsystem(String spielname) throws Exception { + this.spiel = new Spiel(spielname); + } + + public String getSpielname() { + return spiel.getSpielname(); + } + + +} diff --git a/src/fascade/test.java b/src/fascade/test.java deleted file mode 100644 index 34b7391..0000000 --- a/src/fascade/test.java +++ /dev/null @@ -1,5 +0,0 @@ -package fascade; - -public class test { - -} diff --git a/src/main/main.java b/src/infrastructure/Persistenz.java similarity index 63% rename from src/main/main.java rename to src/infrastructure/Persistenz.java index 6d95572..ee60023 100644 --- a/src/main/main.java +++ b/src/infrastructure/Persistenz.java @@ -1,6 +1,6 @@ -package main; +package infrastructure; -public class main { +public class Persistenz { public static void main(String[] args) { // TODO Auto-generated method stub diff --git a/src/infrastructure/test.java b/src/infrastructure/test.java deleted file mode 100644 index b3d90c8..0000000 --- a/src/infrastructure/test.java +++ /dev/null @@ -1,5 +0,0 @@ -package infrastructure; - -public class test { - -} diff --git a/src/main/Main.java b/src/main/Main.java new file mode 100644 index 0000000..fbe3443 --- /dev/null +++ b/src/main/Main.java @@ -0,0 +1,14 @@ +package main; + +import facade.Spielsystem; +import ui.UI; + +public class Main { + + public static void main(String[] args) throws Exception { + Spielsystem spielsystem = new Spielsystem("Hennen und Füchse"); + UI ui = new UI(spielsystem); + + } + +} diff --git a/src/ui/UI.java b/src/ui/UI.java new file mode 100644 index 0000000..e1aa1f2 --- /dev/null +++ b/src/ui/UI.java @@ -0,0 +1,60 @@ +package ui; + +import java.util.Scanner; +import facade.Spielsystem; + +public class UI { + private Spielsystem spielsystem; + Scanner sc = new Scanner(System.in); + + public UI(Spielsystem spielsystem) { + this.spielsystem = spielsystem; + hauptmenü(); + } + + private void hauptmenü() { + System.out.println("Willkommen beim Spiel des Jahres: " + spielsystem.getSpielname() + "!"); + + mainloop: + while (true) { + System.out.println(); + System.out.println("--------"); + System.out.println("Hauptmenü"); + System.out.println("1 -> Neues Spiel starten"); + + System.out.println("10 -> Beenden"); + System.out.println(); + + System.out.print("> "); + int input = 0; + + try { + input = Integer.parseInt(sc.nextLine()); + } catch (NumberFormatException nfe) { + System.out.println("Leider haben Sie keine Zahl eingegeben. Bitte geben Sie eine Zahl ein:"); + } + System.out.println(); + + try { + switch(input) { + case 1: spielStarten(); break; + case 10: break mainloop; + } + + } catch (Exception e) { + System.err.println(e.getLocalizedMessage()); + } + System.out.println(); + } + + System.out.println("Auf Wiedersehen!"); + + } + // hauptmenü + // case 1: + private void spielStarten() { + // TODO Auto-generated method stub + } + + +}