Exemplo n.º 1
0
 public GodOfDeath(ZooRepo zoo, int period)
 {
     Period = period;
     Zoo    = zoo;
     SetWatchPeriod(Period);
     WatchFor(Zoo);
     WakeUp();
 }
Exemplo n.º 2
0
        private void TouchSomebody(object source, ElapsedEventArgs e, ZooRepo zoo)
        {
            var victim = zoo.GetRandomAnimal();

            if (victim != null)
            {
                victim.ChangeStatus();
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Create zoo repository
            var zoo = new ZooRepo();

            zoo.AddAnimalsForDebug();

            // Create God of death :)
            var Anubis = new GodOfDeath();

            Anubis.SetWatchPeriod(5000);
            Anubis.WatchFor(zoo);
            Anubis.WakeUp();

            // Create menu and app logic
            var engine = new Engine(zoo);

            // Run app logic
            engine.Run();
        }
Exemplo n.º 4
0
 public void WatchFor(ZooRepo zoo)
 {
     Zoo             = zoo;
     _timer.Elapsed += (sender, e) => TouchSomebody(sender, e, Zoo);
 }
Exemplo n.º 5
0
 public Engine(ZooRepo zoo)
 {
     this.zoo = zoo;
 }