public void PredictWeather() { int index = weatherConditions.IndexOf(condition); int accuracy = UserInterface.RandomNumber(0, 2); int error = UserInterface.RandomNumber(0, 1); if (index == 0) { error = 0; } else if (index == weatherConditions.Count - 1) { error = 1; } if (accuracy > 0) { predictedForecast = condition; } else { if (error == 0) { predictedForecast = weatherConditions[index + 1]; } else { predictedForecast = weatherConditions[index - 1]; } } }
public Weather() { weatherConditions = new List <string> { "Snowy", "Rainy", "Overcast", "Clear", "Sunny" }; temperature = UserInterface.RandomNumber(30, 100); condition = weatherConditions[UserInterface.RandomNumber(0, 4)]; PredictWeather(); PredictTemperature(); }
public double CalculateTempAndWeatherFactors() { double tempFactor = temp; double customerVarietyFactor = UserInterface.RandomNumber(0, 100); double weatherFactor = UserInterface.DetermineWeatherFactor(weather); likelyToBuy = (tempFactor + weatherFactor + customerVarietyFactor) / 3; return(likelyToBuy); }
public int GetCrowdSize() { double baseCrowd = UserInterface.RandomNumber(75, 120); double weatherFactor = UserInterface.DetermineWeatherFactor(weather.condition); double newCrowd = Math.Floor(((weatherFactor / 100 * 1.5) + .2) * baseCrowd); int crowdInt = Convert.ToInt32(newCrowd); return(crowdInt); }
public void PredictTemperature() { int error = UserInterface.RandomNumber(0, 1); if (error == 0) { predictedTemp = temperature - UserInterface.RandomNumber(0, 10); } else { predictedTemp = temperature + UserInterface.RandomNumber(0, 10); } }
public bool CustomerApproachesStand(double price, int ice, int lemons, int sugar) { double likely = LikelynessToBuy(price, ice, lemons, sugar); double chance = UserInterface.RandomNumber(0, 100); if (likely < chance) /// is the chance (out of 100) beyond the range they are likely to buy { didBuy = false; return(false); } else { didBuy = true; return(true); } }