예제 #1
0
 public void NotifyInvoker(MartialArtist artist)
 {
     if (artist == this.firstArtist)
     {
         this.secondArtist.ResponseToRespect();
     }
     else if (artist == this.secondArtist)
     {
         this.firstArtist.ResponseToRespect();
     }
 }
예제 #2
0
        public void AddArtist(MartialArtist artist, int position)
        {
            switch (position)
            {
            case 1:
                this.firstArtist = artist;
                break;

            case 2:
                this.secondArtist = artist;
                break;

            default:
                Console.WriteLine("Position only accepts 1 or 2");
                break;
            }
        }
        public static void ExecuteTest()
        {
            MartialArtist artistOne = new MartialArtist("Bhima");
            MartialArtist artistTwo = new MartialArtist("Duryodhana");

            Invoker mediator = new Invoker();

            mediator.AddArtist(artistOne, 1);
            mediator.AddArtist(artistTwo, 2);

            artistOne.EstablishMediator(mediator);
            artistTwo.EstablishMediator(mediator);

            artistOne.PayRespects();
            Thread.Sleep(1000);
            artistTwo.PayRespects();
        }