Beispiel #1
0
 private void triggerDoor() {
   if (!door.isOpen()) {
     door.open();
   } else {
     System.out.println("SYSTEM: The dog door is already open.");
   }
 }
Beispiel #2
0
  public void recognize(Bark bark) {
    System.out.println(" Bark recognizer: Heard a '" + bark.getSound() + "'");

    //        if (door.getAllowedBark().equalsq(bark))
    if (door.getAllowedBark().contains(bark)) door.open();
    else System.out.println("This dog is not allowed.");
  }
  public static void main(String[] args) {
    DogDoor door = new DogDoor();
    Remote remote = new Remote(door);
    remote.pressButton();
    while (door.isOpen() == true) ;

    for (int i = 0; i < 10; i++) {
      remote.pressButton();
    }
  }
Beispiel #4
0
 private boolean isBarkRecognized(Bark bark) {
   int matches =
       CollectionUtils.countMatches(door.getAllowedBarks(), PredicateUtils.equalPredicate(bark));
   return matches > 0;
 }