示例#1
0
        public int generatePurchaseChance(Lemonade recipe, Weather forcast)
        {
            int chanceToPurchase = randomSeed.Next(1, 20);

            if (forcast.getTempurature() > 75 && recipe.getIceCubes() > 2)
            {
                chanceToPurchase += 4;
            }

            double CTPDouble = ((recipe.getPrice() + 1) / 3);

            CTPDouble         = Math.Floor(CTPDouble);
            chanceToPurchase -= Convert.ToInt32(CTPDouble);

            int wateredDown = (recipe.getSugar() + recipe.getLemons()) - recipe.getIceCubes();

            if (wateredDown > 0)
            {
                chanceToPurchase += 2;
            }
            else
            {
                chanceToPurchase -= wateredDown;
            }

            return(chanceToPurchase);
        }
示例#2
0
        public bool enoughIngredients(Lemonade recipe)
        {
            if (lemonBasket.Count < recipe.getLemons() || numOfIceCubes < recipe.getIceCubes() || numOfSugar < recipe.getSugar())
            {
                return(false);
            }

            return(true);
        }
示例#3
0
        //to do check for valid ingredients
        public double simulateDay(Lemonade pitcher, Weather forcast)
        {
            Inventory playerInventory   = player1.getInventory();
            Customers customerInstance  = new Customers(pitcher, forcast);
            int       numberOfCustomers = generateNumberOfCustomers(pitcher, forcast);
            double    profit            = 0;

            if (!playerInventory.enoughIngredients(pitcher))
            {
                return(0);
            }
            player1.decrementIngredients(pitcher);
            for (int i = 0; i < numberOfCustomers; i++)
            {
                Customers currentCustomer = new Customers(pitcher, forcast);

                if (currentCustomer.isBuying() && playerInventory.areEnoughCups())
                {
                    pitcher.decrementCups();
                    playerInventory.decrementCups();
                    player1.addMoney(pitcher.getPrice());
                    profit += pitcher.getPrice();

                    if (pitcher.isEmpty())
                    {
                        if (playerInventory.enoughIngredients(pitcher))
                        {
                            player1.decrementIngredients(pitcher);
                            pitcher = new Lemonade(pitcher.getLemons(), pitcher.getSugar(), pitcher.getIceCubes(), pitcher.getPrice());
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return(profit);
        }
示例#4
0
 public void decrementIngredients(Lemonade recipe)
 {
     playerInventory.subtractIceCubes(recipe.getIceCubes());
     playerInventory.subtractLemons(recipe.getLemons());
     playerInventory.subtractSugar(recipe.getSugar());
 }