private void printMenu(Iterator iterator) { while (iterator.hasNext()) { MenuItem menuItem = (MenuItem)iterator.next(); Console.WriteLine(menuItem.getName() + ", "); Console.WriteLine(menuItem.getPrice() + " -- "); Console.WriteLine(menuItem.getDescription()); } }
// Start is called before the first frame update void Start() { BookShelf bookShelf = new BookShelf(4); bookShelf.appendBook(new Book("Around the World in Days")); bookShelf.appendBook(new Book("Bible")); bookShelf.appendBook(new Book("Ciderella")); bookShelf.appendBook(new Book("Daddy-Long-Legs")); Iterator it = bookShelf.iterator(); while (it.hasNext()) { Book book = (Book)it.next(); Debug.Log(book.getName()); } }