예제 #1
0
        private bool chanceToBuy(Customer customer, double chanceMultiplier)
        {
            double chance = random.NextDouble();

            if (customer.isRegular || chance < (customer.chanceOfPurchasing * chanceMultiplier))
            {
                return(true);
            }
            //customer becomes a regular if their inherent chance is the exact same as the determined chance of purchasing
            else if (chance == (customer.chanceOfPurchasing * chanceMultiplier))
            {
                customer.MakeRegular(this);
                Console.WriteLine("{0} has become a regular of your lemonade stand!\nNow they'll always visit!");
                return(true);
            }
            else
            {
                return(false);
            }
        }