bookshelf = $bookshelf; $this->index = 0; } public function hasNext() { if ($this->index < $this->bookshelf->getLength()) { return true; } else { return false; } } public function & next() { $book = $this->bookshelf->getBookAt($this->index); $this->index++; return $book; } } ?>