コード例 #1
0
        public static void DogDoorTestPath(int dogOutsideTime, bool ownersResponsive)
        {
            DogDoor door = new DogDoor();
            BarkRecognizer recognizer = new BarkRecognizer(door);
            Remote remote = new Remote(door);

            Console.WriteLine("\nFido barks to go outside ...");
            InitiateDoorOpen(ownersResponsive, remote, recognizer);

            Console.WriteLine("\nFido has gone outside for " + dogOutsideTime/1000 + " seconds ...");
            System.Threading.Thread.Sleep(dogOutsideTime);
            Console.WriteLine("\nFido's all done ...");

            bool firstBark = true;
            while (!door.isOpen)
            {
                if (firstBark)
                {
                    Console.WriteLine("\n... But he's stuck outside!");
                    Console.WriteLine("\nFido starts barking ...");
                    firstBark = false;
                    InitiateDoorOpen(ownersResponsive, remote, recognizer);
                }
            }

            Console.WriteLine("\nFido's back inside ...");

            while(door.isOpen)
            {
                // Wait
            }
        }
コード例 #2
0
        public static void DogDoorTestPath(int dogOutsideTime, bool ownersResponsive)
        {
            DogDoor        door       = new DogDoor();
            BarkRecognizer recognizer = new BarkRecognizer(door);
            Remote         remote     = new Remote(door);

            Console.WriteLine("\nFido barks to go outside ...");
            InitiateDoorOpen(ownersResponsive, remote, recognizer);

            Console.WriteLine("\nFido has gone outside for " + dogOutsideTime / 1000 + " seconds ...");
            System.Threading.Thread.Sleep(dogOutsideTime);
            Console.WriteLine("\nFido's all done ...");

            bool firstBark = true;

            while (!door.isOpen)
            {
                if (firstBark)
                {
                    Console.WriteLine("\n... But he's stuck outside!");
                    Console.WriteLine("\nFido starts barking ...");
                    firstBark = false;
                    InitiateDoorOpen(ownersResponsive, remote, recognizer);
                }
            }

            Console.WriteLine("\nFido's back inside ...");

            while (door.isOpen)
            {
                // Wait
            }
        }
コード例 #3
0
        public static void DogDoorTestPath(int dogOutsideTime)
        {
            DogDoor door = new DogDoor();
            Remote remote = new Remote(door);

            Console.WriteLine("\nFido barks to go outside ...");
            remote.pressButton();

            Console.WriteLine("\nFido has gone outside for " + dogOutsideTime/1000 + " seconds ...");
            System.Threading.Thread.Sleep(dogOutsideTime);
            Console.WriteLine("\nFido's all done ...");

            bool firstBark = true;
            while (!door.isOpen)
            {
                if (firstBark)
                {
                    Console.WriteLine("\n... But he's stuck outside!");
                    Console.WriteLine("\nFido starts barking ...");
                    firstBark = false;
                    Console.WriteLine("\nSo Gina grabs the remote control ...");
                    remote.pressButton();
                }
            }

            Console.WriteLine("\nFido's back inside ...");

            while(door.isOpen)
            {
                // Wait
            }
            Console.WriteLine("\nTest passed! Press any key to continue.\n");
            
            Console.ReadKey();
        }
コード例 #4
0
        public static int DogDoorTestPath(int dogOutsideTime, bool ownersResponsive)
        {
            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);

            bool isOwnersDog = true;

            Console.WriteLine("\nBruce barks to go outside ...");
            InitiateDoorOpen(ownersResponsive, isOwnersDog, remote, recognizer);

            Console.WriteLine("\nBruce has gone outside for " + dogOutsideTime / 1000 + " seconds ...");
            System.Threading.Thread.Sleep(dogOutsideTime);
            Console.WriteLine("\nBruce is all done ...");

            bool firstBark = true;

            while (!door.isOpen)
            {
                if (firstBark)
                {
                    Console.WriteLine("\n... But he's stuck outside!");
                    firstBark = false;

                    // A different dog barks
                    if (!ownersResponsive)
                    {
                        InitiateDoorOpen(ownersResponsive, !isOwnersDog, remote, recognizer);
                        if (door.isOpen)
                        {
                            Console.WriteLine("\nAnother dog besides Bruce has come inside! ...");
                            return(1);
                        }
                        Console.WriteLine("\nThis dog is not allowed ...");
                    }


                    // Bruce barks
                    InitiateDoorOpen(ownersResponsive, isOwnersDog, remote, recognizer);
                    if (door.isOpen)
                    {
                        Console.WriteLine("\nBruce is back inside ...");
                    }
                }
            }

            while (door.isOpen)
            {
                // Wait
            }

            return(0);
        }
コード例 #5
0
        public static int DogDoorTestPath(int dogOutsideTime, bool ownersResponsive)
        {
            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);

            bool isOwnersDog = true;

            Console.WriteLine("\nBruce barks to go outside ...");
            InitiateDoorOpen(ownersResponsive, isOwnersDog, remote, recognizer);

            Console.WriteLine("\nBruce has gone outside for " + dogOutsideTime/1000 + " seconds ...");
            System.Threading.Thread.Sleep(dogOutsideTime);
            Console.WriteLine("\nBruce is all done ...");

            bool firstBark = true;
            while (!door.isOpen)
            {
                if (firstBark)
                {
                    Console.WriteLine("\n... But he's stuck outside!");
                    firstBark = false;

                    // A different dog barks
                    if (!ownersResponsive)
                    {
                        InitiateDoorOpen(ownersResponsive, !isOwnersDog, remote, recognizer);
                        if (door.isOpen)
                        {
                            Console.WriteLine("\nAnother dog besides Bruce has come inside! ...");
                            return 1;
                        }
                        Console.WriteLine("\nThis dog is not allowed ...");
                    }
                    

                    // Bruce barks
                    InitiateDoorOpen(ownersResponsive, isOwnersDog, remote, recognizer);
                    if (door.isOpen)
                    {
                        Console.WriteLine("\nBruce is back inside ...");
                    }
                }
            }

            while(door.isOpen)
            {
                // Wait
            }

            return 0;
        }
コード例 #6
0
        public static void dogDoorTest()
        {
            DogDoor door   = new DogDoor();
            Remote  remote = new Remote(door);

            Console.WriteLine("Fido barks to go outside ...");
            remote.pressButton();
            Console.WriteLine("\nFido has gone outside ...");
            remote.pressButton();
            Console.WriteLine("\nFido's all done ...");
            remote.pressButton();
            Console.WriteLine("\nFido's back inside ...");
            remote.pressButton();
            Console.ReadKey();
        }
コード例 #7
0
        public static void dogDoorTest()
        {
            DogDoor door = new DogDoor();
            Remote remote = new Remote(door);

            Console.WriteLine("Fido barks to go outside ...");
            remote.pressButton();
            Console.WriteLine("\nFido has gone outside ...");
            remote.pressButton();
            Console.WriteLine("\nFido's all done ...");
            remote.pressButton();
            Console.WriteLine("\nFido's back inside ...");
            remote.pressButton();
            Console.ReadKey();
        }
コード例 #8
0
        public static void DogDoorTestPath(int dogOutsideTime)
        {
            DogDoor door   = new DogDoor();
            Remote  remote = new Remote(door);

            Console.WriteLine("\nFido barks to go outside ...");
            remote.pressButton();

            Console.WriteLine("\nFido has gone outside for " + dogOutsideTime / 1000 + " seconds ...");
            System.Threading.Thread.Sleep(dogOutsideTime);
            Console.WriteLine("\nFido's all done ...");

            bool firstBark = true;

            while (!door.isOpen)
            {
                if (firstBark)
                {
                    Console.WriteLine("\n... But he's stuck outside!");
                    Console.WriteLine("\nFido starts barking ...");
                    firstBark = false;
                    Console.WriteLine("\nSo Gina grabs the remote control ...");
                    remote.pressButton();
                }
            }

            Console.WriteLine("\nFido's back inside ...");

            while (door.isOpen)
            {
                // Wait
            }
            Console.WriteLine("\nTest passed! Press any key to continue.\n");

            Console.ReadKey();
        }
コード例 #9
0
ファイル: Remote.cs プロジェクト: MarkPThomas/HeadFirst-OOAD
 public Remote(DogDoor door)
 {
     _door = door;
     _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed_CloseDoor);
 }
コード例 #10
0
 public Remote(DogDoor door)
 {
     _door = door;
 }
コード例 #11
0
ファイル: Remote.cs プロジェクト: MarkPThomas/HeadFirst-OOAD
 public Remote(DogDoor door)
 {
     _door = door;
 }
コード例 #12
0
 public BarkRecognizer(DogDoor door)
 {
     _door = door;
 }
コード例 #13
0
ファイル: Remote.cs プロジェクト: edisongt/MTVersionHFOOAD
 public Remote(DogDoor door)
 {
     _door           = door;
     _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed_CloseDoor);
 }
コード例 #14
0
 public Remote(DogDoor door)
 {
     this.door     = door;
     tSec.Elapsed += new System.Timers.ElapsedEventHandler(OnTimerEvent);
 }