public static function main($args) { $pancakeHouseMenu = new Menu("PANCAKE HOUSE MENU", "Breakfast"); $dinerMenu = new Menu("DINER MENU", "Lunch"); $cafeMenu = new Menu("CAFE MENU", "Dinner"); $dessertMenu = new Menu("DESSERT MENU", "Dessert of course!"); $allMenus = new Menu("ALL MENUS", "All menus combined"); $allMenus->add($pancakeHouseMenu); $allMenus->add($dinerMenu); $allMenus->add($cafeMenu); $pancakeHouseMenu->add(new MenuItem("K&B's Pancake Breakfast", "Pancakes with scrambled eggs, and toast", TRUE, 2.99)); $pancakeHouseMenu->add(new MenuItem("Regular Pancake Breakfast", "Pancakes with fried eggs, sausage", FALSE, 2.99)); $pancakeHouseMenu->add(new MenuItem("Blueberry Pancakes", "Pancakes made with fresh blueberries, and blueberry syrup", TRUE, 3.49)); $pancakeHouseMenu->add(new MenuItem("Waffles", "Waffles, with your choice of blueberries or strawberries", TRUE, 3.59)); $dinerMenu->add(new MenuItem("Vegetarian BLT", "(Fakin') Bacon with lettuce & tomato on whole wheat", TRUE, 2.99)); $dinerMenu->add(new MenuItem("BLT", "Bacon with lettuce & tomato on whole wheat", FALSE, 2.99)); $dinerMenu->add(new MenuItem("Soup of the day", "A bowl of the soup of the day, with a side of potato salad", FALSE, 3.29)); $dinerMenu->add(new MenuItem("Hotdog", "A hot dog, with saurkraut, relish, onions, topped with cheese", FALSE, 3.05)); $dinerMenu->add(new MenuItem("Steamed Veggies and Brown Rice", "A medly of steamed vegetables over brown rice", TRUE, 3.99)); $dinerMenu->add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough bread", TRUE, 3.89)); $dinerMenu->add($dessertMenu); $dessertMenu->add(new MenuItem("Apple Pie", "Apple pie with a flakey crust, topped with vanilla icecream", TRUE, 1.59)); $dessertMenu->add(new MenuItem("Cheesecake", "Creamy New York cheesecake, with a chocolate graham crust", TRUE, 1.99)); $dessertMenu->add(new MenuItem("Sorbet", "A scoop of raspberry and a scoop of lime", TRUE, 1.89)); $cafeMenu->add(new MenuItem("Veggie Burger and Air Fries", "Veggie burger on a whole wheat bun, lettuce, tomato, and fries", TRUE, 3.99)); $cafeMenu->add(new MenuItem("Soup of the day", "A cup of the soup of the day, with a side salad", FALSE, 3.69)); $cafeMenu->add(new MenuItem("Burrito", "A large burrito, with whole pinto beans, salsa, guacamole", TRUE, 4.29)); $waitress = new Waitress($allMenus); $waitress->printVegetarianMenu(); }
public static function main($args) { $pancakeHouseMenu = new PancakeHouseMenu(); $dinerMenu = new DinerMenu(); $waitress = new Waitress($pancakeHouseMenu, $dinerMenu); $waitress->printMenu(); $waitress->printVegetarianMenu(); println("\nCustomer asks, is the Hotdog vegetarian?"); print "Waitress says: "; if ($waitress->isItemVegetarian("Hotdog")) { println("Yes"); } else { println("No"); } println("\nCustomer asks, are the Waffles vegetarian?"); print "Waitress says: "; if ($waitress->isItemVegetarian("Waffles")) { println("Yes"); } else { println("No"); } }
$dinerMenu = new Menu("DINER MENU", "午餐"); $cafeMenu = new Menu("CAFE MENU", "晚餐"); $dessertMenu = new Menu("DESSERT MENU", "甜点!"); $allMenus = new Menu("ALL MENUS", "All menus combined"); $allMenus->add($pancakeHouseMenu); $allMenus->add($dinerMenu); $allMenus->add($cafeMenu); //早餐菜单项 $pancakeHouseMenu->add(new MenuItem("K&B's Pancake Breakfast", "Pancakes with scrambled eggs, and toast", true, 2.99)); $pancakeHouseMenu->add(new MenuItem("Regular Pancake Breakfast", "Pancakes with fried eggs,sausage", false, 2.99)); $pancakeHouseMenu->add(new MenuItem("Blueberry Pancakes", "Pancakes made with fresh blueberries", true, 3.49)); $pancakeHouseMenu->add(new MenuItem("Waffles", "Waffles, with your choice of blueberries or strawberries", true, 3.59)); //午餐菜单项 $dinerMenu->add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce,and a slice of sourdough bread", true, 3.89)); $dinerMenu->add(new MenuItem("Vegetarian BLT", "(Fakin') Bacon with lettuce & tomato on whole wheat", true, 2.99)); $dinerMenu->add(new MenuItem("BLT", "Bacon with lettuce & tomato on whole wheat", false, 2.99)); $dinerMenu->add(new MenuItem("Soup of the day", "Soup of the day, with a side of potato salad", false, 3.29)); $dinerMenu->add(new MenuItem("Hotdog", "A hot dog,with saurkraut relish, onions, topped with cheese", false, 3.05)); $dinerMenu->add($dessertMenu); //甜点 $dessertMenu->add(new MenuItem("Apple Pie", "Apple pie with a flakey crust,toppen with vanilla ice cream", true, 1.59)); $dessertMenu->add(new MenuItem("Cheesecake", "Apple pie with a flakey crust,toppen with vanilla ice cream", true, 1.99)); $dessertMenu->add(new MenuItem("Sorbet", "Apple pie with a flakey crust,toppen with vanilla ice cream", true, 1.89)); //晚餐 $cafeMenu->add(new MenuItem("辣椒炒肉", "很好吃的辣椒炒肉", false, 12.05)); $cafeMenu->add(new MenuItem("跺脚鱼头", "新鲜的鱼头,香喷喷的剁辣椒", false, 23.7)); $waitress = new Waitress($allMenus); //$waitress->printMenu(); $waitress->printVegetarianMenu(); echo '<hr>'; echo file_get_contents('./read.txt');