static void Main(string[] args) { BookShelf bookShelf = new BookShelf(); bookShelf.appendBook(new Book("Around the World in 80 Days")); bookShelf.appendBook(new Book("Bible")); bookShelf.appendBook(new Book("Cinderellda")); bookShelf.appendBook(new Book("Daddy-Long-Leds")); bookShelf.appendBook(new Book("DesignPattern")); Iterator it = bookShelf.iterator(); while (it.hasNext()) { Book book = (Book)it.Next(); Console.WriteLine(book.GetName()); } Console.ReadKey(); }
public BookShelfIterator(BookShelf bookShelf) { this.bookShelf = bookShelf; this.index = 0; }