001package headfirst.iterator.dinermerger;
002
003public class DinerMenu implements Menu {
004        static final int MAX_ITEMS = 6;
005        int numberOfItems = 0;
006        MenuItem[] menuItems;
007
008        public DinerMenu() {
009                menuItems = new MenuItem[MAX_ITEMS];
010
011                addItem("Vegetarian BLT",
012                                "(Fakin') Bacon with lettuce & tomato on whole wheat", true, 2.99);
013                addItem("BLT",
014                                "Bacon with lettuce & tomato on whole wheat", false, 2.99);
015                addItem("Soup of the day",
016                                "Soup of the day, with a side of potato salad", false, 3.29);
017                addItem("Hotdog",
018                                "A hot dog, with saurkraut, relish, onions, topped with cheese",
019                                false, 3.05);
020                addItem("Steamed Veggies and Brown Rice",
021                                "Steamed vegetables over brown rice", true, 3.99);
022                addItem("Pasta",
023                                "Spaghetti with Marinara Sauce, and a slice of sourdough bread",
024                                true, 3.89);
025        }
026
027        public void addItem(String name, String description,
028                        boolean vegetarian, double price)
029        {
030                MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
031                if (numberOfItems >= MAX_ITEMS) {
032                        System.err.println("Sorry, menu is full!  Can't add item to menu");
033                } else {
034                        menuItems[numberOfItems] = menuItem;
035                        numberOfItems = numberOfItems + 1;
036                }
037        }
038
039        public MenuItem[] getMenuItems() {
040                return menuItems;
041        }
042
043        public Iterator createIterator() {
044                return new DinerMenuIterator(menuItems);
045        }
046
047        // other menu methods here
048}