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 {
|
public class OnlineShop {
|
||||||
private static ArrayList<String> LagerList;
|
private static ArrayList<String> LagerList;
|
||||||
|
|
||||||
public static void Start() throws FileNotFoundException {
|
public String [][] Start() throws FileNotFoundException {
|
||||||
LagerList=readFile();
|
LagerList=readFile();
|
||||||
|
String [][]arr= produktArray(LagerList);
|
||||||
|
return arr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String[][] produktArray(ArrayList Lagerlist) throws FileNotFoundException {
|
public String[][] produktArray(ArrayList Lagerlist) throws FileNotFoundException {
|
||||||
LagerList= readFile();
|
|
||||||
String[] Lager = new String[LagerList.size()];
|
String[] Lager = new String[LagerList.size()];
|
||||||
for (int i = 0; i < LagerList.size(); i++){
|
for (int i = 0; i < LagerList.size(); i++){
|
||||||
Lager[i] = LagerList.get(i);
|
Lager[i] = LagerList.get(i);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ public class Warenkorb {
|
||||||
private ArrayList<Produkt> inhalt;
|
private ArrayList<Produkt> inhalt;
|
||||||
|
|
||||||
public Warenkorb() {
|
public Warenkorb() {
|
||||||
|
|
||||||
inhalt = new ArrayList<Produkt>();
|
inhalt = new ArrayList<Produkt>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void produktHinzufügen(Produkt p) {
|
public void produktHinzufügen(Produkt p) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ public class ShopTUI {
|
||||||
|
|
||||||
public static void main(String[] args) throws FileNotFoundException {
|
public static void main(String[] args) throws FileNotFoundException {
|
||||||
System.out.println("Willkommen zum DanDan-Shop!");
|
System.out.println("Willkommen zum DanDan-Shop!");
|
||||||
|
shop= new OnlineShop();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
boolean cont = true;
|
boolean cont = true;
|
||||||
|
|
@ -22,7 +25,8 @@ public class ShopTUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hauptmenü() throws FileNotFoundException {
|
public static boolean hauptmenü() throws FileNotFoundException {
|
||||||
// TODO: hier ein erstes Menü mit bspw.
|
IO.println();
|
||||||
|
IO.println();
|
||||||
IO.println(" << H a u p t m e n ü >> ");
|
IO.println(" << H a u p t m e n ü >> ");
|
||||||
IO.println("1.Produktangebot");
|
IO.println("1.Produktangebot");
|
||||||
IO.println("2.Produktsuche");
|
IO.println("2.Produktsuche");
|
||||||
|
|
@ -30,32 +34,53 @@ public class ShopTUI {
|
||||||
IO.println("4. Bestellungen");
|
IO.println("4. Bestellungen");
|
||||||
IO.println("5. Exit ");
|
IO.println("5. Exit ");
|
||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
|
IO.print(">>");
|
||||||
String eingabe = sc.nextLine();
|
String eingabe = sc.nextLine();
|
||||||
if(eingabe.equalsIgnoreCase("Produktangebot") || eingabe.equalsIgnoreCase("1"))
|
switch (eingabe) {
|
||||||
|
case "1": case "produktangebot": case "Produktangebot": case "Angebot": case "angebot":
|
||||||
produktangebot();
|
produktangebot();
|
||||||
else if (eingabe.equalsIgnoreCase("Produktsuche")|| eingabe.equalsIgnoreCase("2")){
|
break;
|
||||||
} else if (eingabe.equalsIgnoreCase("Warenkorb")||eingabe.equalsIgnoreCase("Mein Warenkorb") ||eingabe.equalsIgnoreCase("3")) {
|
case "2": case "suche": case "Suche": case"produktsuche":
|
||||||
|
//Todo suchfunktiom
|
||||||
} else if (eingabe.equalsIgnoreCase("Bestellungen")|| eingabe.equalsIgnoreCase("4")) {
|
break;
|
||||||
|
case "3": case "warenkorb": case"Warenkorb":
|
||||||
}
|
//Todo warenkorb
|
||||||
// Produktsuche
|
break;
|
||||||
// Warenkorbanzeige
|
case "4": case "bestellungen": case"Bestellungen":
|
||||||
// evtl. Bestellung (kann auch über Warenkorb realisiert werden)
|
//Todo
|
||||||
else if(eingabe.equalsIgnoreCase("exit")|| eingabe.equalsIgnoreCase("5"))
|
break;
|
||||||
|
case "5": case "exit " : case "Exit":
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
|
IO.println("Etwas ist schiefgelaufen, probieren sie es nochmal");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void produktangebot() throws FileNotFoundException {
|
public static void produktangebot() throws FileNotFoundException {
|
||||||
System.out.println("Unser Produktangebot:");
|
System.out.println("Unser Produktangebot:");
|
||||||
shop.Start();
|
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
/* String[] produkte = shop.produktListe();
|
String[][] produkt = shop.Start();
|
||||||
for (int i = 0; i < produkte.length; i++)
|
|
||||||
System.out.println((i+1) + ". " + produkte[i]);*/
|
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 += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
IO.print(helpString);
|
||||||
|
IO.print(" | ");
|
||||||
|
}
|
||||||
|
IO.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue