You will write a personal recipe manager. Your program will let the user add information about his/her favorite food recipes to the system and use commands to edit, sort or search the information. Your program should be a function named MyFavRecipes which takes no arguments and returns no values.

The recipe manager should be capable of accepting commands. Your function should print out a prompt to indicate that the user can enter a command. Your prompt should be a '$' character. At the prompt the user will type a command followed by a set of arguments for the command. Your function will perform whatever action is indicated by the command, and then your program will print a $ character on a new line in order to let the user know that he/she can type a new command. This process will repeat until the user enters the "Exit" command.

Your program should accept the following commands.

1. AddRecipe: This command indicates that the user wants to enter the information about a recipe into the system. It takes four arguments: the name of the recipe, cooking time (in minutes : 0-100) , level of difficulty (1 the easiest and 5 the hardest), and the key ingredient (e.g. milk and sugar), separated by commas. This command adds the information about the new recipe into the system.

2. PrintRecipe: This command prints all the information about the recipes which have been added to the system. It takes no input arguments. The information about each recipe is printed on a separate line. Each line should have four pieces of information on it: the name of the recipe, cooking time, level of difficulty, and the key ingredient, separated by commas.

3. DeleteRecipe: This command indicates that the user wants to delete the information about a recipe from the system. This command should be followed by one argument, the name of the recipe.

4. SortRecipe: This command indicates that the user wants to view a sorted list of recipes. This command should be followed by one argument, either "Time" or Difficulty. It will print the information about the recipes which have been entered into the system, sorted by their cooking time or level of difficulty indicated by the input argument. The information about each recipe is printed on a separate line. Each line should have four pieces of information on it: the name of the recipe, cooking time, level of difficulty, and the key ingredient, separated by commas.

Keep in mind that sorting should be listed in descending order. In case of ties, the ordering is arbitrary.

5. FindByTime: This command searches for all recipes with cooking time below a given threshold (0 to 100). It should be followed by one argument, cooking time threshold. For each recipe in the system with a cooking time below the threshold,the name of the recipe should be printed on a single line.

6. FindByName: This command searches the system for a recipe with a certain name. The command should be followed by one argument, the name of the recipe. If a recipe with the given name is in the system, all the information about it should be printed on a single line: the name of the recipe, cooking time, level of difficulty, and the key ingredient, separated by commas.

7. FindByIngredient: This command searches the system for a recipe with a certain ingredient. The command should be followed by one argument, the ingredient. If a recipe with the given ingredient exists in the database, all the information about it should be printed on a single line: the name of the recipe, cooking time, level of difficulty, and the key ingredient, separated by commas.

8. Exit: This command should end the program

Example Output

The following output is an example of how your program should respond to commands. The text typed by the user is in bold.

$ ​AddRecipe Pizza, 35, 3, Cheese
$ ​AddRecipe Hamburger, 20, 3, Meat
$ ​AddRecipe Sushi, 45, 5, Seaweed
$ ​AddRecipe Pancake, 20, 2, Flour
$ ​PrintRecipe
Pizza, 35, 3, Cheese
Hamburger, 20, 3, Meat
Sushi, 45, 5, Seaweed
Pancake, 20, 2, Flour
$ ​DeleteRecipe Pancake
$ ​SortRecipe Difficulty
Sushi, 45, 5, Seaweed
Pizza, 35, 3, Cheese
Hamburger, 20, 3, Meat
$ ​FindByTime 30
Hamburger, 20, 3, Meat
$ ​FindByName Pizza
Pizza, 35, 3, Cheese
$ ​FindByIngredient Meat
Hamburger, 20, 3, Meat
$ ​Exit

Additional Details

  • The commands and arguments should be case-sensitive.
  • If the user enters a command which is not valid, your program should not crash. Instead, your program should ignore the command without changing the state of the recipe database, and print a new prompt for the user.
  • Your program will need to maintain a list which contains information about all recipes called ListOfRecipes.
  • Each item in ListOfRecipes should be a namedtuple which contains all information about a recipe. The namedtuple should have 4 fields: the name of the food, cooking time, level of difficulty, and the key ingredient.
  • The AddRecipe command should add a namedtuple to ListOfRecipes, and the DeleteRecipe command should remove a namedtuple from ListOfRecipes.
  • Each function that you define should have a docstring.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.