示例#1
0
        public bool makeDecision(ref LemonadeStand L)
        {
            //decides if they want some lemonade

            Random      rnd      = new Random();
            Func <bool> decision = () => {
                double n = rnd.Next(0, 100) * buyChance;
                if (n > 50)
                {
                    return(true);
                }
                return(false);
            };

            if (decision())
            {
                //buyin some lemonade
                if (this.money > L.getPrice())
                {
                    double cost = L.sellTo(this);
                    this.money -= cost;

                    if (this.likes(L.getRecipe()))
                    {
                        UI.writeLineAt($"{this.name}: Like the lemonade", L.pos);
                        L.incrementPopularity();
                    }
                    else
                    {
                        UI.writeLineAt($"{this.name}: This lemonade is meh", L.pos);
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Console.WriteLine();
                return(false);
            }
        }