Beispiel #1
0
        //Was soll passieren, wenn der Nutzer ein anderes Element in der ListBox auswählt
        private void listBoxKaffeemaschine_SelectedValueChanged(object sender, EventArgs e)
        {
            if (listBoxKaffeemaschine.SelectedItem == null)
            {
                return;
            }

            //MessageBox.Show("Nichts ausgewählt");

            KaffeemaschinenArten art = (KaffeemaschinenArten)listBoxKaffeemaschine.SelectedItem;

            switch (art)
            {
            case KaffeemaschinenArten.PadMaschine:
                _ausgewählteMaschine = _padmaschine;
                break;

            case KaffeemaschinenArten.Vollautomat:
                _ausgewählteMaschine = _vollautomat;
                break;

            case KaffeemaschinenArten.Filtermaschine:
                _ausgewählteMaschine = _filtermaschine;
                break;

            default:
                throw new Exception("Unbekannte Maschinenart!");
            }

            labelKaffeebeschreibung.Text = _ausgewählteMaschine.ToString();
        }
Beispiel #2
0
        private void BestelleNeuenKaffee()
        {
            _bestellteMenge = _random.Next(1, 11) * 100;
            KaffeemaschinenArten kaffeeArt = (KaffeemaschinenArten)_random.Next(1, 4);

            switch (kaffeeArt)
            {
            case KaffeemaschinenArten.PadMaschine:
                _bestellteSorte = typeof(PadMaschine);
                //Alternativ über die Instanz
                //_bestellteSorte = _padmaschine.GetType();
                labelBestellung.Text = $"{_bestellteMenge} ml Espresso bitte!";
                break;

            case KaffeemaschinenArten.Vollautomat:
                _bestellteSorte      = typeof(Vollautomat);
                labelBestellung.Text = $"{_bestellteMenge} ml Cappuccino bitte!";

                break;

            case KaffeemaschinenArten.Filtermaschine:
                _bestellteSorte      = typeof(FilterMaschine);
                labelBestellung.Text = $"{_bestellteMenge} ml Kaffee bitte!";
                break;

            default:
                throw new Exception("Unbekannte Maschinenart");
            }
        }