Example #1
0
 public void MakeBaby(Dad d, string babyName)
 {
     Console.WriteLine($"{Name} made a Baby with {d.Name}");
     Child = new Baby(babyName);
     Child.AddComforter(Comfort);
     Child.AddComforter(d.EscapeToMexico);
 }
Example #2
0
 public void MakeBaby(Dad d, string babyName)
 {
     Console.WriteLine($"Mum {Name} made a Baby with Dad {d.Name}");
     Child = new Baby(babyName);
     Child.AddComforter(this);
     Child.AddComforter(d);
 }
Example #3
0
 public void MakeBaby(Dad d, string babyName)
 {
     Console.WriteLine($"{Name} made a Baby with {d.Name}");
     Child = new Baby(babyName);
     // Ad un evento posso associare metodi con l'operatore +=.
     // Quindi quando l'evento viene invocato,
     // i metodi "agganciati" vengono chiamati. In ordine.
     Child.Cries += Comfort;
     Child.Cries += d.EscapeToMexico;
 }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("A long long time ago, in a galaxy far away...");

            var mum = new Mum("Leila");
            var dad = new Dad("Han Solo");

            mum.MakeBaby(dad, "Kylo Ren");
            mum.Child.StartCrying();

            Console.Read();
        }
Example #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("A long long time ago, in a galaxy far away...");

            var mum = new Mum("Leila");
            var dad = new Dad("Han Solo");

            mum.MakeBaby(dad, "Kylo Ren");
            mum.Child.StartsCrying();
            mum.Child.StartsCrying();
            mum.Child.StartsCrying();
            mum.Child.Cries += b =>
            {
                Console.WriteLine($"The Force feels the evil of {mum.Child.Name}");
                Console.WriteLine($"The Force balances the evil with the birth of Rey");
            };
            mum.Child.StartsCrying();

            Console.Read();
        }