static void Main(string[] args) { //拥有四本空书的书架 BookShelf bookShelf = new BookShelf(); //增加四本书进去 bookShelf.appendBook(new Book("Around the World in 80 Days")); bookShelf.appendBook(new Book("Blble")); bookShelf.appendBook(new Book("Cinderella")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); Iiterator it = bookShelf.iterator(); while (it.hasNext()) { Book book = (Book)it.next(); Console.WriteLine(book.getName()); } }
static void Main(string[] args) { BookShelf bookShelf = new BookShelf(4); bookShelf.appendBook(new Book("Around the world in 80 days")); bookShelf.appendBook(new Book("Bible")); bookShelf.appendBook(new Book("Cinderella")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); Iterator iterator = bookShelf.iterator(); Iterator invIterator = bookShelf.inverseIterator(); // 順方向にスキャンする while (iterator.hasNext()) { Book book = (Book)iterator.next(); Console.WriteLine(book.getName()); } // 逆方向にスキャンする while (invIterator.hasNext()) { Book book = (Book)invIterator.next(); Console.WriteLine(book.getName()); } }
static void Main(string[] args) { BookShelf bookShelf = new BookShelf(5); bookShelf.AddBook(new Book("자바 디자인 패턴")); bookShelf.AddBook(new Book("자바의 정석")); bookShelf.AddBook(new Book("jsp/servlet 3.0")); bookShelf.AddBook(new Book("데이터베이스")); Iterator it = bookShelf.iterator(); while (it.HasNext()) { Book books = (Book)it.Next(); Console.Write(books.GetName()); } }
static void Main(string[] args) { BookShelf bookShelf = new BookShelf(4); bookShelf.AppendBook(new Book("test1")); bookShelf.AppendBook(new Book("test2")); bookShelf.AppendBook(new Book("test3")); bookShelf.AppendBook(new Book("test4")); IIterator it = bookShelf.iterator(); while (it.hasNext()) { Book book = (Book)it.next(); Console.WriteLine(book.Name); } EndConsoleOut(); }