94 lines
3.3 KiB
Java
94 lines
3.3 KiB
Java
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: \n");
|
|
shop.produkteListe();
|
|
}
|
|
|
|
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 Anzeige der Produktinformationen, " + (shop.lager.size() + 1) + " um zum Hauptmenü zurückzukehren)");
|
|
Scanner scanner = new Scanner(System.in);
|
|
int produktNr = scanner.nextInt();
|
|
if (produktNr == 0) {
|
|
shop.produkteInformationen();
|
|
continue;
|
|
} else if (produktNr == shop.lager.size() + 1) {
|
|
break;
|
|
}
|
|
int eingabe = 0;
|
|
System.out.println("Wie viele möchten Sie in Warenkorb legen?");
|
|
scanner = new Scanner(System.in);
|
|
int menge = scanner.nextInt();
|
|
System.out.println("(" + shop.lager.get(produktNr - 1) + ") " + 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) {
|
|
produktsuche();
|
|
}
|
|
else if (eingabe == 2) {
|
|
hauptmenu();
|
|
}
|
|
else{ System.out.println("Probieren Sie es erneut");}
|
|
} else if (eingabe == 2) {
|
|
produktsuche();
|
|
}
|
|
System.out.println("Probieren Sie es erneut.");
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|