51 lines
1.5 KiB
D
51 lines
1.5 KiB
D
module dinermenu;
|
|
|
|
import menu, menuitem, iterator, dinermenuiterator;
|
|
import std.stdio : writeln;
|
|
|
|
class DinerMenu : Menu
|
|
{
|
|
static const int MAX_ITEMS = 6;
|
|
private int numberOfItems = 0;
|
|
private MenuItem[] menuItems;
|
|
|
|
this()
|
|
{
|
|
menuItems = new MenuItem[MAX_ITEMS];
|
|
|
|
addItem("Vegetarian BLT", "(Fakin') Bacon with lettuce & tomato on whole wheat", true, 2.99);
|
|
addItem("BLT", "Bacon with lettuce & tomato on whole wheat", false, 2.99);
|
|
addItem("Soup of the day", "Soup of the day, with a side of potato salad", false, 3.29);
|
|
addItem("Hotdog", "A hot dog, with sauerkraut, relish, onions, topped with cheese", false, 3.05);
|
|
addItem("Steamed Veggies and Brown Rice", "Steamed vegetables over brown rice", true, 3.99);
|
|
addItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough bread", true, 3.89);
|
|
}
|
|
|
|
void addItem(string name, string description, bool vegetarian, double price)
|
|
{
|
|
if (numberOfItems >= MAX_ITEMS)
|
|
{
|
|
writeln("Sorry, menu is full! Can't add item to menu");
|
|
}
|
|
else
|
|
{
|
|
menuItems[numberOfItems++] = new MenuItem(name, description, vegetarian, price);
|
|
}
|
|
}
|
|
|
|
MenuItem[] getMenuItems()
|
|
{
|
|
return menuItems;
|
|
}
|
|
|
|
override Iterator createIterator()
|
|
{
|
|
return new DinerMenuIterator(menuItems);
|
|
}
|
|
|
|
override string toString() const @safe pure nothrow
|
|
{
|
|
return "Diner Menu";
|
|
}
|
|
}
|