Пример #1
0
 public void BuyIce()
 {
     icePrice = 0.10;
     try
     {
         Console.WriteLine("Ice is 10 cents per unit");
         Console.WriteLine("How many would you like?");
         int numberRequested = (int.Parse(Console.ReadLine()));
         int i;
         for (i = 0; i < numberRequested; i++)
         {
             if (PlayerEins.GetMoney() > icePrice)
             {
                 PlayerEins.AddIce();
                 PlayerEins.MoneyForIce();
             }
             else
             {
                 Console.WriteLine("You have bought " + i);
                 Console.WriteLine("You cant afford any more");
                 break;
             }
         }
         Console.WriteLine("Your current balance is : " + Math.Round(PlayerEins.GetMoney(), 2));
         StoreFront();
     }
     catch (System.FormatException)
     {
         Console.WriteLine("Invalid Answer");
         BuyIce();
     }
 }
Пример #2
0
        public void RunGame()
        {
            //Game Generate weather
            string todaysWeather = DisplayDailyWeather(day.weather.conditions);

            Message.DisplayMessage(todaysWeather);

            //Player Fill inventory
            Message.DisplayMessage(String.Format("Your current inventory is {0} lemons, {1} cups of sugar, and {2} cups", player.inventory.lemons.Count, player.inventory.sugars.Count, player.inventory.cups.Count));
            store.GetLemons();
            player.AddLemons(store.lemonQty, player.wallet);
            Message.DisplayMessage("New balance: $" + player.wallet.balance);
            store.GetSugar();
            player.AddSugar(store.sugarQty, player.wallet);
            Message.DisplayMessage("New balance: $" + player.wallet.balance);
            store.GetIce();
            player.AddIce(store.iceQty, player.wallet);
            Message.DisplayMessage("New balance: $" + player.wallet.balance);
            store.GetCups();
            player.AddCups(store.cupQty, player.wallet);
            Message.DisplayMessage("New balance: $" + player.wallet.balance);
            spentBalance = 20 - player.wallet.balance;

            //Player set recipe
            ShowRecipe();
            GetNewRecipe(player);

            //Player Set Price
            player.SetPrice();
            player.inventory.GetNewPitcher(player.inventory.pitcher);

            //Create customers//demand
            int customerQty = day.GetCustomerQty();

            day.GenerateCustomer(customerQty);
            day.GetDemand();
            bool buy = day.GetCustomerBuy();

            player.inventory.CheckNewPitcher(player.cupsSold);
            bool empty  = player.inventory.CheckInventory();
            bool endDay = player.CheckCanSell(empty, buy);



            //End day
            day.EndDay();

            //TESTS //working
            //weather.DisplayTest();
            //int lemonQty = inventory.GetLemons();
            //inventory.AddLemons(lemonQty, wallet);
            //Console.WriteLine(wallet.balance);
            //Console.WriteLine(player.inventory.cups.Count + player.inventory.icecubes.Count + player.inventory.lemons.Count + player.inventory.sugars.Count);
            //Console.WriteLine(player.inventory.cups.Count + player.inventory.icecubes.Count + player.inventory.lemons.Count + player.inventory.sugars.Count);

            //TEST INPUT
            //Console.WriteLine("Enter a number");
            //string userInput = Console.ReadLine();
            //bool isInteger = Message.CheckIntegerInput(userInput);
            //Console.WriteLine(isInteger);
            //Message.DisplayMessage("This Customer Demand: " + customer.demand);
            //TEST CUSTOMER DEMAND
        }