Пример #1
0
        public void MakeBaby(Dad dad, string name)
        {
            Baby baby = new Baby(name);

            Child               = baby;
            dad.Child           = baby;
            baby.StartedCrying += dad.ComfortChild;
            baby.StartedCrying += ComfortChild;
            Console.WriteLine($"{Name} ha fatto un figlio con {dad.Name}, che si chiama {baby.Name}");
        }
Пример #2
0
        static void Main(string[] args)
        {
            Robot r2d2 = new Robot("R2D2");

            Mum leila   = new Mum("Leila");
            Dad hanSolo = new Dad("Han Solo");

            leila.MakeBaby(hanSolo, "Kylo Ren");

            leila.Child.StartedCrying += r2d2.Comfort;
            leila.Child.StartedCrying += TheForce.ComfortChild;

            // NON posso invocare un evento fuori dalla classe
            // in cui l'ho dichiarato.
            //leila.Child.StartedCrying.Invoke(leila.Child);

            Console.Read();
        }
Пример #3
0
        public override void Run(IGUI guiHandler)
        {
            Mum   leila   = new Mum("Leila");
            Dad   hanSolo = new Dad("Han Solo");
            Robot r2d2    = new Robot("R2D2");
            Baby  benSolo = leila.MakeBaby(hanSolo, "Ben Solo");

            //benSolo.AddComforter(r2d2.Comfort);

            benSolo.StartedCrying += r2d2.Comfort;
            benSolo.StartedCrying += TheForce.ComfortChild;

            //benSolo.StartCrying();
            //benSolo.StartCrying();
            //benSolo.StartCrying();
            //benSolo.StartCrying();
            //benSolo.StartCrying();

            //benSolo.AddComforter(TheForce.ComfortChild);
            //benSolo.StartCrying();


            Console.ReadKey();
        }
Пример #4
0
 public void Comfort(Dad dad)
 {
     Console.WriteLine($"{Name} dà una pacca sulla spalla a {dad.Name}");
 }