001package headfirst.iterator.transition;
002import java.util.ArrayList;
003import java.util.Iterator;
004
005
006@SuppressWarnings("rawtypes")
007public class Waitress {
008        ArrayList menus;
009
010
011        public Waitress(ArrayList menus) {
012                this.menus = menus;
013        }
014
015        public void printMenu() {
016                Iterator menuIterator = menus.iterator();
017                while(menuIterator.hasNext()) {
018                        Menu menu = (Menu)menuIterator.next();
019                        printMenu(menu.createIterator());
020                }
021        }
022
023        void printMenu(Iterator iterator) {
024                while (iterator.hasNext()) {
025                        MenuItem menuItem = (MenuItem)iterator.next();
026                        System.out.print(menuItem.getName() + ", ");
027                        System.out.print(menuItem.getPrice() + " -- ");
028                        System.out.println(menuItem.getDescription());
029                }
030        }
031}