Restaurant menu
Created on Feb. 24, 2022 by Driikolu
Implement a Dish and a Menu classes like so:
- Dish have a
name,preparation_time, and adish_typeattribute , given in this order at initialization time. -
Dish's
dish_typeattribute value can be :- starter
- dish
- dessert
-
Menu have a
nameattribute, given at initialization time. - Menu have an
add_dish(dish)method. - When you compare 2
Dishitems with the operators>,<,==,<=,>=, it must compare itspreparation_time. - Menu have a
get_starters()method giving all the Dish with "starter"dish_type - Menu have a
get_dishes()method giving all the Dish with "dish"dish_type -
Menu have a
get_desserts()method giving all the Dish with "dessert"dish_type -
Menu have a
get_minimum_preparation_time()method giving the sum of :- the lowest
preparation_timefrom Dish with "starter"dish_typeon the Menu (0 if there is no starter) - the lowest
preparation_timefrom Dish with "dish"dish_typeon the Menu (0 if there is no dish) - the lowest
preparation_timefrom Dish with "dessert"dish_typeon the Menu (0 if there is no dessert)
- the lowest
-
Menu have a
get_maximum_preparation_time()method giving the sum of :- the highest
preparation_timefrom Dish with "starter"dish_typeon the Menu (0 if there is no starter) - the highest
preparation_timefrom Dish with "dish"dish_typeon the Menu (0 if there is no dish) - the highest
preparation_timefrom Dish with "dessert"dish_typeon the Menu (0 if there is no dessert)
- the highest
-
When you add 2
Menuitems with the+operator, it will return a third Menu containing the dishes (starters, dishes, desserts) of the 2 Menu and withnamebeing the 2 Menunameseparated by " & ".
eg :
1 2 3 4 5 | |
-
When you print a
Menuitem it must :- Print all the Dish's
name1 per line sorted bydish_type(starter, dish, dessert) andpreparation_time(lowest to highest) - Separate every
dish_typeby an empty line - Adding the
dish_typeall in uppercase before all the Dish with the givendish_type
- Print all the Dish's
Here is what it should look like :
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
There's no corrections yet, hit the `Submit` button to send your code to the correction bot.
Keyboard shortcuts:
- Ctrl-Enter: Send your code to the correction bot.
- Escape: Get back to the instructions tab.