For some reason which I can't figure out, my static method ShuffleProbability() only runs once during the creation of objects.
I was hoping that for each object creation it would go into the ShuffleProbability method and generate either false/true and set the property IsHungry to the returned value?
I was hoping that for each object creation it would go into the ShuffleProbability method and generate either false/true and set the property IsHungry to the returned value?
C#:
public void CreateDummyAnimals()
{
//Create dummy animals at start
Petowner.Pets.Add(new Cat
{
Name = "Missy",
IsHungry = ShuffleProbability(),
});
Petowner.Pets.Add(new Dog
{
Name = "Bruno",
IsHungry = ShuffleProbability(),
});
}
ShuffleProbability method:
public static bool ShuffleProbability()
{
// Shuffles a bool value with 50% probaility
Random random = new Random();
bool randomNumber = random.Next(0, 2) > 0;
return randomNumber;
}