Exemplo n.º 1
0
 private void Obey(Sergant s, EventArgs e)
 {
     if (_patience >= 0)
     {
         Console.WriteLine("{0} says to Sergant {1}: Yes, sir!", Name, s.Name);
         _patience--;
     }
     else
     {
         Console.WriteLine("{0} says: F**k you, Sergant {1}, I'm tired!", Name, s.Name);
         s.Shout -= Obey;
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Sergant bilko = new Sergant("Bilko");

            Soldier john  = new Soldier("John", 4);
            Soldier peter = new Soldier("Peter", 6);
            Soldier jerry = new Soldier("Jerry", 8);

            john.Subscribe(bilko);
            peter.Subscribe(bilko);
            jerry.Subscribe(bilko);

            bilko.StartGivingOrders();

            Console.ReadLine();
        }
Exemplo n.º 3
0
 public void Subscribe(Sergant s)
 {
     s.Shout += Obey;
 }