コード例 #1
0
        public void SetTodaysWeather()
        {
            string[] forecastSplit = predictedForecast.Split();

            string cond = "";

            for (int i = 0; i < forecastSplit.Length - 1; i++)
            {
                cond += forecastSplit[i];
                if (i != forecastSplit.Length - 2)
                {
                    cond += " ";
                }
            }


            if (MyRandom.Next(10) < 2)
            {
                condition   = GetRandomWeatherCondition();
                temperature = RandomTemperature(condition);
            }
            else
            {
                condition   = cond;
                temperature = MyRandom.Next(-5, 6) + Int32.Parse(forecastSplit[forecastSplit.Length - 1]);
            }

            SetBuyChance();
        }
コード例 #2
0
        private int Brain(int input)
        {
            int thoughts;

            thoughts = MyRandom.Next(input - 1, input + 1);

            return(thoughts);
        }
コード例 #3
0
        public int DetermineRealNumberOfCustomers()
        {
            string[] splitForecast = predictedForecast.Split();

            int numCustomers = Int32.Parse(splitForecast[splitForecast.Length - 1]);
            int upper        = numCustomers / 2;
            int lower        = upper - (2 * upper);

            return(numCustomers + MyRandom.Next(lower, upper + 1));
        }
コード例 #4
0
        private double Brain(double input)
        {
            double thoughts;

            thoughts = MyRandom.Next((Convert.ToInt32(input * 100) + 5) - (Convert.ToInt32(input * 100) - 5));

            thoughts /= 100;

            return(thoughts);
        }
コード例 #5
0
        public bool CheckIfBuy(Weather weather, Recipe recipe)
        {
            bool willBuy = false;

            double averageBuyChance = (weather.buyChance + recipe.buyChance + buyChance) / 3;

            if (MyRandom.Next(1, 101) < averageBuyChance)
            {
                willBuy = true;
            }

            return(willBuy);
        }
コード例 #6
0
        public int RandomTemperature(string currentCondition)
        {
            int temp = 0;

            switch (currentCondition)
            {
            case ("Sunny"):
                temp = MyRandom.Next(75, 96);
                break;

            case ("Cloudy"):
                temp = MyRandom.Next(65, 75);
                break;

            case ("Rainy"):
                temp = MyRandom.Next(50, 65);
                break;

            case ("Stormy"):
                temp = MyRandom.Next(45, 61);
                break;

            case ("Snowing"):
                temp = MyRandom.Next(0, 33);
                break;

            case ("Windy"):
                temp = MyRandom.Next(40, 75);
                break;

            case ("Icy"):
                temp = MyRandom.Next(-10, 21);
                break;

            default:
                break;
            }
            return(temp);
        }
コード例 #7
0
 public string GetRandomWeatherCondition()
 {
     return(weatherConditions[MyRandom.Next(0, weatherConditions.Count)]);
 }
コード例 #8
0
 public void SetRealWeatherForcast()
 {
     predictedForecast = condition + " " + (temperature + MyRandom.Next(-10, 11));
 }
コード例 #9
0
 public void SetBuyChance()
 {
     buyChance = MyRandom.Next(30, 75);
 }