コード例 #1
0
        //will generate a random amount of customers according weather and temp.
        public void GetTotalCustomers(Random rnd, Recipe recipe)
        {
            Demand demand = new Demand(recipe, weather);

            if (weather.temperature == "Hot" && weather.condition == "and sunny")
            {
                int customerNumber = rnd.Next(35, 40);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
            else if (weather.temperature == "Hot" && weather.condition == "and cloudy")
            {
                int customerNumber = rnd.Next(30, 34);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
            else if (weather.temperature == "Hot" && weather.condition == "with thunderstorms")
            {
                int customerNumber = rnd.Next(20, 29);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
            else if (weather.temperature == "Warm" && weather.condition == "and sunny")
            {
                int customerNumber = rnd.Next(25, 31);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
            else if (weather.temperature == "Warm" && weather.condition == "and cloudy")
            {
                int customerNumber = rnd.Next(20, 24);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
            else if (weather.temperature == "Warm" && weather.condition == "with thunderstorms")
            {
                int customerNumber = rnd.Next(15, 19);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
            else if (weather.temperature == "Cold" && weather.condition == "and sunny")
            {
                int customerNumber = rnd.Next(5, 11);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
            else if (weather.temperature == "Cold" && weather.condition == "and cloudy")
            {
                int customerNumber = rnd.Next(0, 10);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
            else if (weather.temperature == "Cold" && weather.condition == "with thunderstorms")
            {
                int customerNumber = rnd.Next(0, 4);
                for (int i = 0; i < customerNumber; i++)
                {
                    customers.Add(new Customer(demand));
                }
            }
        }
コード例 #2
0
        //Constructor (spawner)//

        //Member methods (what it does)//
        public Customer(Demand demand)
        {
            CustomerBuyProbability(demand);
        }