Source code for cozmo_taste_game.food.food_props

from .food_prop import FoodProp
from .food_group import FoodGroup


[docs]class Hotdog(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'hotdog' @property def food_groups(self): return [FoodGroup.protein] @property def color(self): return 'red'
[docs]class Watermelon(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'watermelon' @property def food_groups(self): return [FoodGroup.fruit] @property def color(self): return 'red'
[docs]class Grapes(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'grapes' @property def color(self): return 'green'
[docs]class Broccoli(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'broccoli' @property def food_groups(self): return [FoodGroup.vegetable] @property def color(self): return 'green'
[docs]class Milk(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'milk' @property def color(self): return 'white'
[docs]class Banana(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'banana' @property def color(self): return 'yellow'
[docs]class Blueberry(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'blueberry' @property def color(self): return 'blue'
[docs]class Cupcake(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'cupcake' @property def color(self): return 'pink'
[docs]class Cheese(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'cheese' @property def color(self): return 'yellow'
[docs]class Carrot(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'carrot' @property def color(self): return 'orange'
[docs]class Orange(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'orange' @property def color(self): return 'orange'
[docs]class Corn(FoodProp): def __init__(self): super().__init__() def __str__(self): return 'corn' @property def color(self): return 'yellow'
[docs]def get_food(food_type: str): """ Factory function :param food_type: String representing what food to return :return: Reference to the suitable static food object :exception: KeyError if food_type isn't in dictionary """ food_type = food_type.lower() return { "hotdog": Hotdog(), "watermelon": Watermelon(), "broccoli": Broccoli(), "grapes": Grapes(), "blueberry": Blueberry(), "cupcake": Cupcake(), "banana": Banana(), "carrot": Carrot(), "cheese": Cheese(), "milk": Milk(), "orange": Orange(), "corn": Corn() }[food_type]