private void GenerateAnimal() { var rnd = new Random(); var prob = rnd.Next(0, 100); Animal newAnimal = null; if (prob < 25) { newAnimal = new Rat(_zoo); } else if (prob < 35) { newAnimal = new Elephant(_zoo); } else if (prob < 70) { newAnimal = new Cat(_zoo); } else if (prob < 95) { newAnimal = new Dog(_zoo); } else if (prob < 100) { newAnimal = new Snake(_zoo); } var elt = new EarthLiveTicker(); elt.Unsubscribe(newAnimal); //EarthLiveTicker.LiveTicker.Subscribe(newAnimal); _zoo.Receive(newAnimal); }
static void Main(string[] args) { Logger.Log("Starting program"); var thread = new Thread(() => { var zoo = new Zoo(); var elt = new EarthLiveTicker(); elt.Subscribe(zoo); //EarthLiveTicker.LiveTicker.Subscribe(zoo); var animalProvider = new AnimalProvider(zoo); elt.Subscribe(animalProvider); //EarthLiveTicker.LiveTicker.Subscribe(animalProvider); }); thread.Start(); Logger.Log("Animan provider started working"); Console.ReadKey(); Console.ReadKey(); }