示例#1
0
        static void Main(string[] args)
        {
            DogDoor door = new DogDoor();

            door.AddAllowedBarks(new Bark("rowlf"));
            door.AddAllowedBarks(new Bark("roooowlf"));
            door.AddAllowedBarks(new Bark("rawlf"));
            door.AddAllowedBarks(new Bark("woof"));
            Console.WriteLine(door.AllowedBarks.Count);
            // Remote remote = new Remote(door);
            BarkRecognizer recognizer = new BarkRecognizer(door);

            Console.WriteLine("Bruce starts barking... ");
            recognizer.Recognize(new Bark("rowlf"));

            Console.WriteLine("Bruce has gone outside..");

            // recognizer.Recognize("woof");
            // remote.PressButton();
            Thread.Sleep(5000);

            Console.WriteLine("Bruce is all done ");
            Console.WriteLine("But he's stuck outside");
            Bark smallDogBark = new Bark("Yip");

            Console.WriteLine("A small dog starts barking..");
            recognizer.Recognize(smallDogBark);
            Thread.Sleep(5000);

            Console.WriteLine("Bruce starts barking.. ");
            recognizer.Recognize(new Bark("rooowlf"));
            // remote.PressButton();
            Console.WriteLine("Bruce's back inside..");
        }
示例#2
0
        static void Main(string[] args)
        {
            DogDoor door   = new DogDoor();
            Remote  remote = new Remote(door);
            Thread  Test   = new Thread(DogComeBacks);

            Console.WriteLine("Dog is barking...to go out!");

            remote.PressButton();
            Console.WriteLine("Button is pressed....");
            Test.Start();
        }
示例#3
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("Dog starts barking.");
            recognizer.Recognize(new Bark("Rowlf"));

            Console.WriteLine("\nDog has gone outside...");

            try
            {
                Thread.Sleep(10000);
            }
            catch
            {
            }

            Console.WriteLine("\nDog 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(5000);
            }
            catch
            {
            }

            Console.WriteLine("\nDog starts barking.");
            recognizer.Recognize(new Bark("Rowlf"));

            Console.WriteLine("\nDog is back inside...");
            Console.ReadKey();
        }
示例#4
0
        static void Main(string[] args)
        {
            var door = new DogDoor();

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

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

            Console.WriteLine("Bruce starts Barking...");
            recognizer.Recognize(new Bark("rowlf"));
            Console.WriteLine("Bruce has gone outside....");

            try
            {
                Thread.Sleep(10000);;
            }
            catch (Exception exception) { }

            Console.WriteLine("Bruce 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(5000);
            }
            catch (Exception exception) { }

            Console.WriteLine("Bruce Starts Barking....");
            recognizer.Recognize(new Bark("rowlf"));
            Console.WriteLine("Bruce's back inside....");
        }
示例#5
0
 public Remote(DogDoor _door)
 {
     this._door = _door;
 }
示例#6
0
 public BarkRecognizer(DogDoor door)
 {
     _door = door;
 }
示例#7
0
 public Remote(DogDoor door)
 {
     _closedoor = new Thread(AutoDoorClose);
     this._door = door;
 }
示例#8
0
 public Remote(DogDoor door)
 {
     _door = door;
 }
示例#9
0
 public Remote(DogDoor door)
 {
     this.door = door;
 }
示例#10
0
 public BarkRecognizer(DogDoor door)
 {
     this.door = door;
 }