From bb8f189652c10fc6d59d3cf73c34b9d43b03fb72 Mon Sep 17 00:00:00 2001
From: "igor.lewandowski" <3029957@stud.th-mannheim.de>
Date: Wed, 10 Dec 2025 20:37:15 +0100
Subject: [PATCH] =?UTF-8?q?Grundger=C3=BCst=20(ShopTUI=20+=20Objekte=20Onl?=
=?UTF-8?q?ineShop,=20Warenkorb,=20Produkt=20und=20die=20jeweilige=20Struk?=
=?UTF-8?q?tur=20initialisieren)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/.gitignore | 8 ++++
.idea/OnlineShop.iml | 11 +++++
.idea/misc.xml | 6 +++
.idea/modules.xml | 8 ++++
.idea/vcs.xml | 6 +++
resources/produkte.csv | 8 ++++
src/ShopTUI.java | 106 +++++++++++++++++++++++++++++++++++++++++
7 files changed, 153 insertions(+)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/OnlineShop.iml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 resources/produkte.csv
create mode 100644 src/ShopTUI.java
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/OnlineShop.iml b/.idea/OnlineShop.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/.idea/OnlineShop.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..188022c
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..1772ae0
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/produkte.csv b/resources/produkte.csv
new file mode 100644
index 0000000..d267731
--- /dev/null
+++ b/resources/produkte.csv
@@ -0,0 +1,8 @@
+ProdId,Name,TransportGewicht,Netto,MwStSatz,Lagerbestand
+1,Riesling 0.7 l,1.2,4.20,19,87
+2,Pfälzer Saumagen 250 g,0.28,2.52,7,23
+3,Gewürznelken 100 St.,0.01,2.52,7,3
+4,Kokosmilch 250 ml,0.275,1.67,7,12
+5,Bratwurst grob 250 g,0.258,2.09,7,17
+6,Traubensaft 1.0 l,1.5,2.93,19,1
+7,Gieskanne,0.2,3.80,19,13
\ No newline at end of file
diff --git a/src/ShopTUI.java b/src/ShopTUI.java
new file mode 100644
index 0000000..c731748
--- /dev/null
+++ b/src/ShopTUI.java
@@ -0,0 +1,106 @@
+import java.io.FileNotFoundException;
+import java.util.Scanner;
+
+public class ShopTUI {
+ public static OnlineShop shop;
+ public static void main(String[] args) throws FileNotFoundException {
+ System.out.println("Willkommen im Lewandowski Store!");
+ shop = new OnlineShop();
+ produktangebot();
+ hauptmenu();
+ }
+
+ public static void hauptmenu() throws FileNotFoundException {
+ System.out.println("Was möchten Sie tun?");
+ System.out.println("(1=Produktsuche, 2=Warenkorbanzeige, 3=Bestellung abschließen, 0=Programm beenden): ");
+
+ while (true) {
+
+ Scanner scanner = new Scanner(System.in);
+ int wahl = scanner.nextInt();
+
+ switch (wahl) {
+ case 1:
+ produktsuche();
+ break;
+
+ case 2:
+ shop.warenkorbAusgabe();
+ break;
+
+ case 3:
+ break;
+
+ case 0:
+ System.exit(0);
+ break;
+
+ default: System.out.println("Falsche Eingabe!");
+ continue;
+ }
+ }
+ }
+ public static void produktangebot() throws FileNotFoundException {
+ System.out.println("Diese Produkte bieten wir an: ");
+ System.out.println("");
+ String[] produkte = shop.produkteListe();
+ for (int i = 0; i < produkte.length; i++) {
+ System.out.println(produkte[i]);
+ }
+ }
+
+ public static void produktsuche() throws FileNotFoundException {
+ while (true) {
+ System.out.println("Geben Sie das gewünschte Produkt mit der ProduktNr an");
+ System.out.println("(0 für erneute Anzeige der Produkte, " + (shop.lager.size() + 1) + " um zum Hauptmenü zurückzukehren)");
+ Scanner scanner = new Scanner(System.in);
+ int produktNr = scanner.nextInt();
+ if (produktNr == 0) {
+ produktangebot();
+ continue;
+ } else if (produktNr == shop.lager.size() + 1) {
+ break;
+ }
+ System.out.println("Meinen Sie dieses Produkt?");
+ System.out.println(shop.lager.get(produktNr - 1));
+ System.out.println("1=Ja, 2=Nein");
+ scanner = new Scanner(System.in);
+ int eingabe = scanner.nextInt();
+ if (eingabe == 1) {
+ System.out.println("Wie viele möchten Sie in Warenkorb legen?");
+ scanner = new Scanner(System.in);
+ int menge = scanner.nextInt();
+ System.out.println("Dieses Produkt " + menge + " mal in den Warenkorb legen? (1=Ja, 2=Nein)");
+ scanner = new Scanner(System.in);
+ while (true) {
+ eingabe = scanner.nextInt();
+ if (eingabe == 1) {
+ shop.inWarenkorb(produktNr, menge);
+ System.out.println("Möchten Sie ein weiteres Produkt hinzufügen? (1=Ja, 2=Nein)");
+ scanner = new Scanner(System.in);
+ eingabe = scanner.nextInt();
+ if (eingabe == 1) {
+ continue;
+ }
+ else if (eingabe == 2) {
+ hauptmenu();
+ }
+ else{ System.out.println("Probieren Sie es erneut");}
+ } else {
+ System.out.println("Probieren Sie es erneut.");
+ continue;
+ }
+ }
+ }
+ else if(eingabe == 2) {
+ continue;
+ }
+ else {
+ System.out.println("Probieren Sie es erneut.");
+ continue;
+ }
+
+ }
+ }
+ }
+