示例#1
0
文件: Program.cs 项目: war-man/Scuola
 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);
 }
示例#2
0
文件: Program.cs 项目: war-man/Scuola
 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);
 }
示例#3
0
文件: Program.cs 项目: war-man/Scuola
 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;
 }
示例#4
0
文件: Program.cs 项目: war-man/Scuola
        public void Comfort(Baby b)
        {
            Console.WriteLine($"{Name} comforts {b.Name}");

            if (!_isExhausted)
            {
                _isExhausted = true;
            }
            else
            {
                b.RemoveComforter(Comfort);
            }
        }
示例#5
0
文件: Program.cs 项目: war-man/Scuola
        public void Comfort(Baby b)
        {
            Console.WriteLine($"{Name} comforts {b.Name}");

            if (!_isExhausted)
            {
                _isExhausted = true;
            }
            else
            {
                // Posso rimuovere metodi da un evento, con l'operatore -=
                b.Cries -= Comfort;
            }
        }
示例#6
0
文件: Program.cs 项目: war-man/Scuola
        public void EscapeToMexico(Baby b)
        {
            b.RemoveComforter(EscapeToMexico);

            Console.WriteLine($"{Name} escapes to Mexico!");
        }
示例#7
0
文件: Program.cs 项目: war-man/Scuola
 public void Comfort(Baby b)
 {
     Console.WriteLine($"{Name} gives a caress to the {b.Name}");
 }
示例#8
0
文件: Program.cs 项目: war-man/Scuola
        public void EscapeToMexico(Baby b)
        {
            Console.WriteLine($"{Name} escapes to Mexico!");

            b.Cries -= EscapeToMexico;
        }
示例#9
0
文件: Program.cs 项目: war-man/Scuola
 public void Comfort(Baby b)
 {
     Console.WriteLine($"Mum {Name} comforts Baby {b.Name}");
 }
示例#10
0
文件: Program.cs 项目: war-man/Scuola
 public void EscapeToMexico(Baby b)
 {
     // ? how can I do this?
 }