Beispiel #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);
        }
Beispiel #2
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);
        }