コード例 #1
0
 private void FillChooseEatBox(СuisineFactory cuisineFactory)
 {
     chooseEatBox.Items.Clear();
     chooseEatBox.Items.Add(cuisineFactory.CreateSoup().Name);
     chooseEatBox.Items.Add(cuisineFactory.CreateDumplings().Name);
     chooseEatBox.Items.Add(cuisineFactory.CreateCake().Name);
     chooseEatBox.Items.Add(cuisineFactory.CreateIceCream().Name);
     chooseEatBox.Enabled       = true;
     chooseEatBox.SelectedIndex = 0;
 }
コード例 #2
0
        private void chooseEatBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string text = "";

            switch (chooseEatBox.SelectedIndex)
            {
            case 0:
                var soup = _cuisineFactory.CreateSoup();
                text  = $"Название: {soup.Name}\n\n";
                text += $"Категория: {soup.category}\n\n";
                text += $"Ингридиенты:\n{soup.GetIngredients()}";
                break;

            case 1:
                var dumplings = _cuisineFactory.CreateDumplings();
                text  = $"Название: {dumplings.Name}\n\n";
                text += $"Категория: {dumplings.category}\n\n";
                text += $"Ингридиенты:\n{dumplings.GetIngredients()}";
                break;

            case 2:
                var cake = _cuisineFactory.CreateCake();
                text  = $"Название: {cake.Name}\n\n";
                text += $"Категория: {cake.category}\n\n";
                text += $"Ингридиенты:\n{cake.GetIngredients()}";
                break;

            case 3:
                var icecream = _cuisineFactory.CreateIceCream();
                text  = $"Название: {icecream.Name}\n\n";
                text += $"Категория: {icecream.category}\n\n";
                text += $"Ингридиенты:\n{icecream.GetIngredients()}";
                break;
            }
            resultTextBox.Text = text;
        }