-
Notifications
You must be signed in to change notification settings - Fork 23
/
PancakeHouseMenu.java
50 lines (40 loc) · 1.5 KB
/
PancakeHouseMenu.java
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
47
48
49
50
package Cafe;
import DinerAndPancakeHouseIterator.MenuItem;
import java.util.ArrayList;
import java.util.Iterator;
public class PancakeHouseMenu implements Menu {
ArrayList menuItems;
public PancakeHouseMenu() {
menuItems = new ArrayList();
// each menu item is added to the ArrayList here, in the constructor
addItem("K&B' Pancake Breakfast",
"Pancake with scrambled eggs, and toast",
true,
2.99);
addItem("Regular Pancake Breakfast",
"Pancake with fried eggs, sausage",
false,
2.99);
addItem("Blueberry Pancakes",
"Pancakes made with fresh blueberries",
true,
3.49);
addItem("Waffles",
"Waffles, with your choice of blueberries or strawberries",
true,
3.59);
}
public void addItem(String name,
String description,
boolean vegetarian,
double price) {
// to add a menu item, creates a new MenuItem object, passing in each argument, and then adds it to the ArrayList
MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
menuItems.add(menuItem);
}
public Iterator createIterator() {
// instead of creating our own iterator now
// we just call the iterator() method on the menuItems ArrayList
return menuItems.iterator();
}
}