-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPancakeHouseMenu.java
More file actions
46 lines (36 loc) · 1.28 KB
/
PancakeHouseMenu.java
File metadata and controls
46 lines (36 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package IteratorPattern.MenuExample;
import java.util.ArrayList;
public class PancakeHouseMenu {
ArrayList<MenuItem> menuItems;
public PancakeHouseMenu() {
menuItems = new ArrayList<MenuItem>();
addItem("K&B's Pancake Breakfast",
"Pancakes with scrambled eggs, and toast",
true,
2.99);
addItem("Regular Pancake Breakfast",
"Pancakes with fried eggs, sausage",
true,
2.99);
addItem("Blueberry Pancakes",
"Pancakes made with fresh blueberries",
true,
3.49);
addItem("Waffles",
"Waffles with your choice of toppings",
true,
3.59);
}
public void addItem(String name, String description, boolean vegetarian, double price){
MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
menuItems.add(menuItem);
}
// After setting up iterator this isn't needed anymore
// It exposes the internal structure
// public ArrayList<MenuItem> getMenuItems() {
// return menuItems;
// }
public Iterator createIterator() {
return new PancakeHouseMenuIterator(menuItems);
}
}