public void Recognize(Bark bark)
        {
            Console.WriteLine("Bark Recognizer : Heard a '" + bark.Sound + "'");
            List <Bark>        allowedBarks = _door.GetAllowedBark;
            IEnumerator <Bark> iterator     = allowedBarks.GetEnumerator();

            while (iterator.MoveNext())
            {
                Bark allowedBark = (Bark)iterator.Current;
                if (allowedBark.Equals(bark))
                {
                    _door.Open();
                    return;
                }
            }
            Console.WriteLine("Dog is not allowed");
        }
示例#2
0
        public void Recognize(Bark bark)
        {
            Console.WriteLine("   BarkRecognizer: Heard a '" + bark.Sound
                              + "'");
            List <Bark> allowedBarks = door.AllowedBark;

            foreach (Bark b in allowedBarks)
            {
                Bark allowedBark = b;
                if (allowedBark.Equals(bark))
                {
                    door.Open();
                    return;
                }
            }
            Console.WriteLine("This Dog is not Allowed..");
        }