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 } }
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 } }
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(); }
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); }
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; }
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(); }
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(); }
public Remote(DogDoor door) { _door = door; _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed_CloseDoor); }
public Remote(DogDoor door) { _door = door; }
public BarkRecognizer(DogDoor door) { _door = door; }
public Remote(DogDoor door) { this.door = door; tSec.Elapsed += new System.Timers.ElapsedEventHandler(OnTimerEvent); }