Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            DogDoor door = new DogDoor();

            door.AddAllowedBark(new Bark("rowlf"));
            door.AddAllowedBark(new Bark("rooowlf"));
            door.AddAllowedBark(new Bark("rawlf"));
            door.AddAllowedBark(new Bark("woof"));

            BarkRecognizer recognizer = new BarkRecognizer(door);
            Remote         remote     = new Remote(door);

            Console.WriteLine();
            Console.WriteLine("Bruce starts barking...");
            recognizer.recognize(new Bark("rowlf"));
            Console.WriteLine("\nBruce has gone outside...");
            try
            {
                Thread.Sleep(10000);
            }
            catch (ThreadInterruptedException e) {
                Console.WriteLine("Error " + e.Message);
            }

            Console.WriteLine("\nBruce all done...");
            Console.WriteLine("...but he's stuck outside!");

            Bark smallDogBark = new Bark("yip");

            Console.WriteLine("A small dog starts barking.");
            recognizer.recognize(smallDogBark);

            try
            {
                Thread.Sleep(10000);
            }
            catch (ThreadInterruptedException e)
            {
                Console.WriteLine("Error " + e.Message);
            }

            Console.WriteLine("\nBruce starts barking...");
            recognizer.recognize(new Bark("rowlf"));
            Console.WriteLine("\nBruce’s back inside...");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            DogDoor        door       = new DogDoor();
            BarkRecognizer recognizer = new BarkRecognizer(door);

            //Remote remote = new Remote(door);
            Console.WriteLine();
            Console.WriteLine("Fido starts barking...");
            recognizer.recognize("Woof");
            Console.WriteLine("\nFido has gone outside...");
            Console.WriteLine("\nFido’s all done...");
            try
            {
                Thread.Sleep(10000);
            }
            catch (ThreadInterruptedException e) {
                Console.WriteLine("Error " + e.Message);
            }

            Console.WriteLine("...but he's stuck outside!");
            Console.WriteLine("\nFido starts barking...");
            recognizer.recognize("Woof");
            Console.WriteLine("\nFido’s back inside...");
        }