Esempio n. 1
0
        private static AbstractMeat ChooseMeatMenu()
        {
            AbstractMeat chosenMeat = null;

            while (chosenMeat == null)
            {
                WriteLine("Choose meat type:\n1. Pork\n2. Chicken\n3. Beef\n");
                switch (ReadLine())
                {
                case "1":
                    chosenMeat = new Pork();
                    break;

                case "2":
                    chosenMeat = new Chicken();
                    break;

                case "3":
                    chosenMeat = new Beef();
                    break;

                case "4":
                    chosenMeat = new Veal();
                    break;

                default:
                    WriteLine("Use 1, 2, 3, 4 to choose meat. Try again.");
                    break;
                }
            }
            return(chosenMeat);
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "Фрукты")
            {
                double         price = double.Parse(textBox1.Text);
                int            count = int.Parse(textBox2.Text);
                AProducts      item  = new Fruits(price, count, (FruitType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem);
                ICrud <Fruits> crud  = new ICrudFruit();
                crud.Create((Fruits)item);
            }
            else if (comboBox1.Text == "Овощи")
            {
                double             price = double.Parse(textBox1.Text);
                int                count = int.Parse(textBox2.Text);
                AProducts          item  = new Vegetables(price, count, (VegetableType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem);
                ICrud <Vegetables> crud  = new ICrudVegetable();
                crud.Create((Vegetables)item);
            }
            else if (comboBox1.Text == "Зелень")
            {
                double             price = double.Parse(textBox1.Text);
                int                count = int.Parse(textBox2.Text);
                AProducts          item  = new Herbaceous(price, count, (HerbaceousType)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem);
                ICrud <Herbaceous> crud  = new ICrudHerbaceous();
                crud.Create((Herbaceous)item);
            }
            else if (comboBox1.Text == "Говядина")
            {
                double       price = double.Parse(textBox1.Text);
                int          count = int.Parse(textBox2.Text);
                AProducts    item  = new Beef(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem);
                ICrud <Beef> crud  = new ICrudBeef();
                crud.Create((Beef)item);
            }
            if (comboBox1.Text == "Свинина")
            {
                double       price = double.Parse(textBox1.Text);
                int          count = int.Parse(textBox2.Text);
                AProducts    item  = new Pork(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem);
                ICrud <Pork> crud  = new ICrudPork();
                crud.Create((Pork)item);
            }
            else if (comboBox1.Text == "Курица")
            {
                double          price = double.Parse(textBox1.Text);
                int             count = int.Parse(textBox2.Text);
                AProducts       item  = new Chicken(price, count, (MeatFactoryName)comboBox2.SelectedItem, (MeatProductType)comboBox3.SelectedItem);
                ICrud <Chicken> crud  = new ICrudChicken();
                crud.Create((Chicken)item);
            }


            else if (comboBox1.Text == "Рыба")
            {
                double       price = double.Parse(textBox1.Text);
                int          count = int.Parse(textBox2.Text);
                AProducts    item  = new Fish(price, count, (FishName)comboBox2.SelectedItem, (DealerCountry)comboBox3.SelectedItem);
                ICrud <Fish> crud  = new ICrudFish();
                crud.Create((Fish)item);
            }
        }
Esempio n. 3
0
        public SkillResponse GetWine(SkillRequest input, ILambdaContext context)
        {
            try
            {
                var requestType = input.GetRequestType();
                if (requestType == typeof(IntentRequest))
                {
                    IFood request   = null;
                    var   intentReq = input.Request as IntentRequest;
                    if (intentReq.Intent.Name == "AMAZON.HelpIntent" || intentReq.Intent.Slots.ContainsKey("meat") == false)
                    {
                        return(ResponseBuilder.Ask("Try asking for a meat to pair.", new Reprompt("Would you like to pair a meat?")));
                    }


                    string intentValue = intentReq.Intent.Slots["meat"].Value;
                    if (intentValue.Contains("beef") ||
                        intentValue.Contains("steak") ||
                        intentValue.Contains("lamb") ||
                        intentValue.Contains("goat") ||
                        intentValue.Contains("veal"))
                    {
                        request = new RedMeat();
                    }
                    else if (intentValue.Contains("cured") ||
                             intentValue.Contains("bacon") ||
                             intentValue.Contains("salami"))
                    {
                        request = new CuredMeat();
                    }
                    else if (intentValue.Contains("pork") ||
                             intentValue.Contains("ham"))
                    {
                        request = new Pork();
                    }
                    else if (intentValue.Contains("chicken") ||
                             intentValue.Contains("poultry") ||
                             intentValue.Contains("light meat") ||
                             intentValue.Contains("dark meat") ||
                             intentValue.Contains("duck") ||
                             intentValue.Contains("turkey") ||
                             intentValue.Contains("goose"))
                    {
                        request = new Poultry();
                    }
                    else if (intentValue.Contains("mollusk") ||
                             intentValue.Contains("clam") ||
                             intentValue.Contains("oyster") ||
                             intentValue.Contains("mussel") ||
                             intentValue.Contains("scallop"))
                    {
                        request = new Mollusk();
                    }
                    else if (intentValue.Contains("shellfish") ||
                             intentValue.Contains("shrimp") ||
                             intentValue.Contains("lobster") ||
                             intentValue.Contains("crab"))
                    {
                        request = new Shellfish();
                    }
                    else if (intentValue.Contains("fish") ||
                             intentValue.Contains("seafood") ||
                             intentValue.Contains("salmon"))
                    {
                        request = new Fish();
                    }


                    if (request == null)
                    {
                        Console.WriteLine("Null request sent to matching service with intentValue: " + intentValue);
                    }

                    var   matches = _winePair.FindBestMatchingWines(request);
                    IWine match1, match2 = match1 = null;
                    if (matches.Count >= 2)
                    {
                        match1 = matches[0];
                        match2 = matches[1];
                    }
                    else if (matches.Count == 1)
                    {
                        match1 = matches[0];
                    }

                    if (match1 == null && match2 == null)
                    {
                        throw new Exception("Could not find matching wine.");
                    }



                    string response;
                    if (match1 != null && match2 != null)
                    {
                        response = string.Format("You should try a {0} wine like {1} or a {2} wine like {3}", match1.Style.ToString(), match1.Name, match2.Style.ToString(), match2.Name);
                    }
                    else
                    {
                        response = string.Format("You should try a {0} wine like {1}", match1.Style.ToString(), match1.Name);
                    }

                    return(ResponseBuilder.Tell(response));
                }
                else if (requestType == typeof(LaunchRequest))
                {
                    var response = ResponseBuilder.Ask("What can I pair for you?", new Reprompt("Would you like to pair a wine?"));
                    response.Response.ShouldEndSession = false;
                    return(response);
                }
            }
            catch (Exception e)
            {
                Console.Write("Exception Caught: ");
                Console.WriteLine(e);
            }

            return(ResponseBuilder.Ask("What would you like to pair?", new Reprompt("What would you like to pair?")));
        }
Esempio n. 4
0
 private void textBox4_TextChanged(object sender, EventArgs e)
 {
     dataGridView1.Rows.Clear();
     if (comboBox1.Text == "Говядина")
     {
         ICrud <Beef> crud = new ICrudBeef();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         Beef product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.MeatProductType;
         comboBox3.SelectedItem = product.MeatFactoryName;
     }
     else if (comboBox1.Text == "Свинина")
     {
         ICrud <Pork> crud = new ICrudPork();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Pork product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.MeatProductType;
         comboBox3.SelectedItem = product.MeatFactoryName;
     }
     else if (comboBox1.Text == "Курица")
     {
         ICrud <Chicken> crud = new ICrudChicken();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Chicken product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.MeatProductType;
         comboBox3.SelectedItem = product.MeatFactoryName;
     }
     else if (comboBox1.Text == "Рыба")
     {
         ICrud <Fish> crud = new ICrudFish();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Fish product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.FishName;
         comboBox3.SelectedItem = product.DealerCountry;
     }
     else if (comboBox1.Text == "Фрукты")
     {
         ICrud <Fruits> crud = new ICrudFruit();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Fruits product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.Type;
         comboBox3.SelectedItem = product.Country;
     }
     else if (comboBox1.Text == "Овощи")
     {
         ICrud <Vegetables> crud = new ICrudVegetable();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Vegetables product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.Type;
         comboBox3.SelectedItem = product.Country;
     }
     else if (comboBox1.Text == "Растительность")
     {
         ICrud <Herbaceous> crud = new ICrudHerbaceous();
         data = crud.ReadAll();
         foreach (string[] s in data)
         {
             dataGridView1.Rows.Add(s);
         }
         crud.ReadByID(Convert.ToInt32(textBox4.Text));
         Herbaceous product = crud.ReadByID(Convert.ToInt32(textBox4.Text));
         textBox2.Text          = product.Price.ToString();
         textBox3.Text          = product.Count.ToString();
         comboBox2.SelectedItem = product.Type;
         comboBox3.SelectedItem = product.Country;
     }
 }