예제 #1
0
 public function removeBook(Book $bookToRemove)
 {
     foreach ($this->books as $key => $book) {
         /** @var Book $book */
         if ($book->getAuthorAndTitle() === $bookToRemove->getAuthorAndTitle()) {
             unset($this->books[$key]);
         }
     }
 }
예제 #2
0
 public function removeBook(Book $bookToRemove)
 {
     foreach ($this->books as $key => $book) {
         if ($book->getAuthorAndTitle() === $bookToRemove->getAuthorAndTitle()) {
             unset($this->books[$key]);
         }
     }
     $this->books = array_values($this->books);
 }
예제 #3
0
 public function removeBook(Book $book_in)
 {
     $counter = 0;
     while (++$counter <= $this->getBookCount()) {
         if ($book_in->getAuthorAndTitle() == $this->books[$counter]->getAuthorAndTitle()) {
             for ($x = $counter; $x < $this->getBookCount(); $x++) {
                 $this->books[$x] = $this->books[$x + 1];
             }
             $this->setBookCount($this->getBookCount() - 1);
         }
     }
     return $this->getBookCount();
 }
 public function removeBook(Book $book_in)
 {
     $counter = 0;
     // goes through all arrays keys of $book[i] for i=0,1...$this->getBookCount() and sets $books[i]=$books[i+1]
     // lowers BookCount by 1
     while (++$counter <= $this->getBookCount()) {
         if ($book_in->getAuthorAndTitle() == $this->books[$counter]->getAuthorAndTitle()) {
             for ($x = $counter; $x < $this->getBookCount(); $x++) {
                 $this->books[$x] = $this->books[$x + 1];
             }
             $this->setBookCount($this->getBookCount() - 1);
         }
     }
     // returns the total number of books available so far
     return $this->getBookCount();
 }