public static void showMenu() { Console.Clear(); int inp, i; Console.WriteLine("\tWas wollen Sie tun?\t"); Console.WriteLine("1 ... Alle Produkte ausgeben"); Console.WriteLine("2 ... Warenkorb ausgeben"); Console.WriteLine("3 ... Produkt kaufen"); try{ switch ((inp = int.Parse(Console.ReadLine()))) { case 1: Verwaltung.print_products(); break; case 2: Verwaltung.print_warenkorb(); break; case 3: Console.WriteLine("\tWas wollen Sie kaufen?\t"); //Console.WriteLine (Verwaltung.getProduktListe().Count); for (i = 0; i <= Verwaltung.getProduktListe().Count - 1; i++) { Console.WriteLine((i + 1).ToString() + " ... " + Verwaltung.getProduktListe()[i].ToString() + "\n"); } switch (int.Parse(Console.ReadLine())) { case 1: Verwaltung.addToWarenkorb(Verwaltung.getProduktListe()[0]); break; case 2: Verwaltung.addToWarenkorb(Verwaltung.getProduktListe()[1]); break; case 3: Verwaltung.addToWarenkorb(Verwaltung.getProduktListe()[2]); break; } break; } }catch (FormatException) { Console.WriteLine("Ihre Eingabe hatte ein falsches Format. Sie werden in 2 Sekunden weitergeleitet."); int milliseconds = 2000; Thread.Sleep(milliseconds); showMenu(); }catch (Exception) { Console.WriteLine("Oops! Ein Fehler ist aufgetreten. Sie werden in 2 Sekunden weitergeleitet."); int milliseconds = 2000; Thread.Sleep(milliseconds); showMenu(); } }
/* EVENT ZONE */ public static void UeberschrittenHandler(/*object sender, EventArgs e*/) { foreach (Gemuese g in Verwaltung.getProduktListe()) { if (g.getAblaufDatum() == ablaufdatum) { Verwaltung.getProduktListe().Remove(g); } } }
public static void initializeProductList(StreamReader sr) { string[] txt; txt = sr.ReadToEnd().Trim().Split('#'); int i = 0; for (i = 0; i <= txt.Length - 1; i++) { switch (txt[i].Split('_') [0].ToLower() /*.Remove(0, 2)*/) { case "obs": Verwaltung.addToProduktListe(new Obst(txt[i].Split('_')[1], txt[i].Split('_')[2], Convert.ToDouble(txt[i].Split('_')[3]), txt[i].Split('_')[4], txt[i].Split('_')[5], Convert.ToInt32(txt[i].Split('_')[6]))); break; case "gem": Verwaltung.addToProduktListe(new Gemuese(txt[i].Split('_')[1], txt[i].Split('_')[2], Convert.ToInt32(txt[i].Split('_')[3]), txt[i].Split('_')[4], txt[i].Split('_')[5])); break; case "obp": Verwaltung.addToProduktListe(new Obstprodukt(txt[i].Split('_')[1], txt[i].Split('_')[2], Convert.ToInt32(txt[i].Split('_')[3]), txt[i].Split('_')[4], txt[i].Split('_')[5], Convert.ToInt32(txt[i].Split('_')[6]))); break; } } }