Print in die TUI gemacht, die if-Anweisung im Hauptmenü zu einem switch case geändert der übesichts wegen
parent
f017bff5e3
commit
8be9721223
|
|
@ -10,14 +10,15 @@ import java.util.Scanner;
|
|||
public class OnlineShop {
|
||||
private static ArrayList<String> LagerList;
|
||||
|
||||
public static void Start() throws FileNotFoundException {
|
||||
public String [][] Start() throws FileNotFoundException {
|
||||
LagerList=readFile();
|
||||
String [][]arr= produktArray(LagerList);
|
||||
return arr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String[][] produktArray(ArrayList Lagerlist) throws FileNotFoundException {
|
||||
LagerList= readFile();
|
||||
String[] Lager = new String[LagerList.size()];
|
||||
for (int i = 0; i < LagerList.size(); i++){
|
||||
Lager[i] = LagerList.get(i);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ public class Warenkorb {
|
|||
private ArrayList<Produkt> inhalt;
|
||||
|
||||
public Warenkorb() {
|
||||
|
||||
inhalt = new ArrayList<Produkt>();
|
||||
|
||||
}
|
||||
|
||||
public void produktHinzufügen(Produkt p) {
|
||||
|
|
|
|||
|
|
@ -6,56 +6,81 @@ import java.util.Scanner;
|
|||
|
||||
|
||||
public class ShopTUI {
|
||||
private static OnlineShop shop;
|
||||
private static OnlineShop shop;
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
System.out.println("Willkommen zum DanDan-Shop!");
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
System.out.println("Willkommen zum DanDan-Shop!");
|
||||
shop= new OnlineShop();
|
||||
|
||||
|
||||
boolean cont= true;
|
||||
|
||||
while(cont){
|
||||
cont=hauptmenü();
|
||||
|
||||
boolean cont = true;
|
||||
|
||||
while (cont) {
|
||||
cont = hauptmenü();
|
||||
}
|
||||
|
||||
System.out.println("Auf Wiedersehen!");
|
||||
}
|
||||
|
||||
public static boolean hauptmenü() throws FileNotFoundException {
|
||||
IO.println();
|
||||
IO.println();
|
||||
IO.println(" << H a u p t m e n ü >> ");
|
||||
IO.println("1.Produktangebot");
|
||||
IO.println("2.Produktsuche");
|
||||
IO.println("3.Mein Warenkorb");
|
||||
IO.println("4. Bestellungen");
|
||||
IO.println("5. Exit ");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
IO.print(">>");
|
||||
String eingabe = sc.nextLine();
|
||||
switch (eingabe) {
|
||||
case "1": case "produktangebot": case "Produktangebot": case "Angebot": case "angebot":
|
||||
produktangebot();
|
||||
break;
|
||||
case "2": case "suche": case "Suche": case"produktsuche":
|
||||
//Todo suchfunktiom
|
||||
break;
|
||||
case "3": case "warenkorb": case"Warenkorb":
|
||||
//Todo warenkorb
|
||||
break;
|
||||
case "4": case "bestellungen": case"Bestellungen":
|
||||
//Todo
|
||||
break;
|
||||
case "5": case "exit " : case "Exit":
|
||||
return false;
|
||||
|
||||
default:
|
||||
IO.println("Etwas ist schiefgelaufen, probieren sie es nochmal");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void produktangebot() throws FileNotFoundException {
|
||||
System.out.println("Unser Produktangebot:");
|
||||
|
||||
String[][] produkt = shop.Start();
|
||||
|
||||
IO.println();
|
||||
for (int i = 0; i < produkt.length; i++) {
|
||||
for (int j = 0; j < produkt[i].length; j++) {
|
||||
String helpString = produkt[i][j];
|
||||
int length = 10;
|
||||
if (j == 1)
|
||||
length = 25;
|
||||
while (helpString.length() != length) {
|
||||
helpString += " ";
|
||||
}
|
||||
|
||||
System.out.println("Auf Wiedersehen!");
|
||||
}
|
||||
|
||||
public static boolean hauptmenü() throws FileNotFoundException {
|
||||
// TODO: hier ein erstes Menü mit bspw.
|
||||
IO.println(" << H a u p t m e n ü >> ");
|
||||
IO.println("1.Produktangebot");
|
||||
IO.println("2.Produktsuche");
|
||||
IO.println("3.Mein Warenkorb");
|
||||
IO.println("4. Bestellungen");
|
||||
IO.println("5. Exit ");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String eingabe = sc.nextLine();
|
||||
if(eingabe.equalsIgnoreCase("Produktangebot") || eingabe.equalsIgnoreCase("1"))
|
||||
produktangebot();
|
||||
else if (eingabe.equalsIgnoreCase("Produktsuche")|| eingabe.equalsIgnoreCase("2")){
|
||||
} else if (eingabe.equalsIgnoreCase("Warenkorb")||eingabe.equalsIgnoreCase("Mein Warenkorb") ||eingabe.equalsIgnoreCase("3")) {
|
||||
|
||||
} else if (eingabe.equalsIgnoreCase("Bestellungen")|| eingabe.equalsIgnoreCase("4")) {
|
||||
|
||||
IO.print(helpString);
|
||||
IO.print(" | ");
|
||||
}
|
||||
// Produktsuche
|
||||
// Warenkorbanzeige
|
||||
// evtl. Bestellung (kann auch über Warenkorb realisiert werden)
|
||||
else if(eingabe.equalsIgnoreCase("exit")|| eingabe.equalsIgnoreCase("5"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void produktangebot() throws FileNotFoundException {
|
||||
System.out.println("Unser Produktangebot:");
|
||||
shop.Start();
|
||||
System.out.println();
|
||||
|
||||
/* String[] produkte = shop.produktListe();
|
||||
for (int i = 0; i < produkte.length; i++)
|
||||
System.out.println((i+1) + ". " + produkte[i]);*/
|
||||
IO.println();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue