public static void Main(string[] args) { BookListAggregate bookListAggregate = new BookListAggregate(); Iterator iterator = bookListAggregate.createIterator(); bookListAggregate.add(new Book("すごい本", 1000)); bookListAggregate.add(new Book("楽しい本", 2000)); bookListAggregate.add(new Book("悲しい本", 3000)); bookListAggregate.add(new Book("面白い本", 4000)); iterator.first(); while (!iterator.isDone()) { Book book = (Book)iterator.getItem(); Console.WriteLine(book.getName() + ":" + book.getPrice() + "円"); iterator.next(); } Console.ReadLine(); }
public BookListIterator(BookListAggregate aggregate) { this.aggregate = aggregate; }