Пример #1
0
        /// <summary>
        /// Reverses the owner and thief.
        /// </summary>
        public void reverseOwnerAndThief()
        {
            OwnerOrThief tmp = this.mOwner;

            this.mOwner = this.mThief;
            this.mThief = tmp;
        }
Пример #2
0
 /// <summary>
 /// Alert dog that a thief sleeps in it basket
 /// </summary>
 /// <param name="sleeper">The current basket sleeper</param>
 public void alert(OwnerOrThief sleeper)
 {
     if (sleeper is Cat)
     {
         Console.WriteLine("# Dog alerted");
     }
 }
Пример #3
0
        /// <summary>
        /// When the owner or the thief sleep in the basket, the owner (or IAlarm) is alerted
        /// </summary>
        /// <param name="sleeper">Current basket sleeper.</param>
        public void sleepIn(OwnerOrThief sleeper)
        {
            Console.WriteLine("# " + sleeper.Name + " sleeps in the basket.");
            this.mSleeper = sleeper;

            if (mOwner is IAlarm)
            {
                ((IAlarm)mOwner).alert(sleeper);
            }
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:languagetour.Basket"/> class using to parameters
 /// </summary>
 /// <param name="owner">Owner: The basket owner</param>
 /// <param name="thief">Thief: The basket thief</param>
 public Basket(OwnerOrThief owner, OwnerOrThief thief)
 {
     this.mOwner   = owner;
     this.mThief   = thief;
     this.mSleeper = null;
 }