Пример #1
0
        public void SellLemonade(Day day, Random random)
        {
            int willBuy = 0;

            foreach (Customer buyingCustomer in day.customer.potentialCustomer)
            {
                willBuy = random.Next(1, 11);

                if (lemonade.cupsOfLemonade.Count != 0)
                {
                    if ((day.weather.temperature >= 70) && (lemonade.LemonadePrice < .50m) && (lemonade.LemonadeType == buyingCustomer.LemonadeTypePreference))
                    {
                        day.customer.purchasingCustomer.Add(buyingCustomer);
                        lemonade.RemoveLemonade();
                    }
                    else if ((day.weather.temperature >= 70) && (lemonade.LemonadePrice >= .50m) && (lemonade.LemonadeType == buyingCustomer.LemonadeTypePreference))
                    {
                        if (willBuy > 3)
                        {
                            day.customer.purchasingCustomer.Add(buyingCustomer);
                            lemonade.RemoveLemonade();
                        }
                    }
                    else if ((day.weather.temperature < 70) && (day.weather.temperature >= 40) && (lemonade.LemonadePrice < .50m) && (lemonade.LemonadeType == buyingCustomer.LemonadeTypePreference))
                    {
                        if (willBuy > 2)
                        {
                            day.customer.purchasingCustomer.Add(buyingCustomer);
                            lemonade.RemoveLemonade();
                        }
                    }
                    else if ((day.weather.temperature < 70) && (day.weather.temperature >= 40) && (lemonade.LemonadePrice >= .50m) && (lemonade.LemonadeType == buyingCustomer.LemonadeTypePreference))
                    {
                        if (willBuy > 3)
                        {
                            day.customer.purchasingCustomer.Add(buyingCustomer);
                            lemonade.RemoveLemonade();
                        }
                    }
                    else if ((day.weather.temperature < 40) && (lemonade.LemonadePrice < .50m) && (lemonade.LemonadeType == buyingCustomer.LemonadeTypePreference))
                    {
                        if (willBuy > 4)
                        {
                            day.customer.purchasingCustomer.Add(buyingCustomer);
                            lemonade.RemoveLemonade();
                        }
                    }
                    else if ((day.weather.temperature < 40) && (lemonade.LemonadePrice >= .50m) && (lemonade.LemonadeType == buyingCustomer.LemonadeTypePreference))
                    {
                        if (willBuy > 6)
                        {
                            day.customer.purchasingCustomer.Add(buyingCustomer);
                            lemonade.RemoveLemonade();
                        }
                    }
                    else if ((day.weather.temperature >= 70) && (lemonade.LemonadePrice < .50m) && (recipe.IceCubesQty >= 6))
                    {
                        if (willBuy > 5)
                        {
                            day.customer.purchasingCustomer.Add(buyingCustomer);
                            lemonade.RemoveLemonade();
                        }
                    }
                    else if ((day.weather.temperature >= 70) && (lemonade.LemonadePrice < .40m))
                    {
                        if (willBuy > 5)
                        {
                            day.customer.purchasingCustomer.Add(buyingCustomer);
                            lemonade.RemoveLemonade();
                        }
                    }
                }
                else if (lemonade.cupsOfLemonade.Count == 0)
                {
                    Console.WriteLine("\nSold Out for today");
                    break;
                }
            }
        }