PROJECT: CookBuddy

Overview

CookBuddy is a desktop recipe manager for students staying in university accommodation who enjoy cooking. They can interact with it through a Command Line Interface (CLI), and it has a Graphical User Interface (GUI) created with JavaFX. It is written in Java, and has about 10 kLoC.

Summary of contributions

  • Major enhancement: Morphed addressbook-level3 into a basic version of CookBuddy. #75

    • What it does: allows my teammates to start working on features to extend CookBuddy.

    • Justification: CookBuddy does not make use of the Person class or its fields like Email & Address.

    • Highlights: This enhancement affects the commands CookBuddy can respond to. For instance, CookBuddy responds to new instead of add.

  • Major enhancement: Created the test framework for CookBuddy. #120

    • What is does: It creates the test framework for my teammates to create test classes for CookBuddy.

    • Justification: This enhancement makes it a bit easier for my teammates to write test classes for CookBuddy.

    • Highlights: The test framework has some sample recipes with initialised attributes to make creating test recipes a bit easier.

  • Minor enhancement: added a Command History feature that allows the user to navigate to previous commands using the page up / page down keys. #289

  • Code contributed: [Code Contributed]

  • Other contributions:

    • Project management:

      • Reviewed pull requests opened by teammates for code quality and bugs (#133, #127, #257)

    • Enhancements to existing features:

      • Refactored the AddCommand command into NewCommand. #77

      • Added a command history to the Command Box so that users can reuse previously entered commands. #289

      • Updated tag parsing from multiple t/ prefixes to a single t/ prefix with comma delimited tags. #255

    • Documentation:

      • Updated the instructions for the new and modify commands in the User Guide. #170

      • Updated the instructions for the find command in the User Guide. #314, #164

      • Added instructions on how to use the find command in the User Guide. #164

      • Added an explanation of how the find command works to the Developer Guide. #323

      • Added Instructions for Manual Testing to the Developer Guide. #302

    • Community:

      • PRs reviewed (with non-trivial review comments): #295, #293, #171, #124, #113

      • Reported bugs and suggestions for other teams during the Practical Exam Dry-Run (examples: 1, 2, 3)

Contributions to the User Guide

Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users.

Adding a recipe — new [Done by Kevin]

You can add a new recipe to CookBuddy using the new command.

Parameters in bold indicate they are mandatory.

Format: new n/NAME ing/INGREDIENT, QUANTITY [; …​] ins/INSTRUCTION [; …​] [p/PATH] [cal/CALORIES] [s/SERVING_SIZE] [r/RATING] [t/TAG [, …​]]

Remember to follow the format specified strictly and carefully.

CookBuddy accepts the following parameters:

  • n/ - name of the recipe

  • ing/ - ingredients in the recipe

  • ins/ - instructions to follow

  • p/ - path of the recipe’s photo

  • cal/ - calories in the recipe (in kcal)

  • s/ - serving size of the recipe (any integer greater than 0)

  • r/ - personal rating of the recipe (any integer between 0-5 inclusive)

  • d/ - difficulty in following the recipe (any integer between 0-5 inclusive)

  • t/ - tags (separated by commas)

Example 1: You can enter new n/Fried Rice ing/White rice, 1 cup; salt, 1 gram ins/Fry the rice; add salt into CookBuddy, and a new recipe with the following attributes will be added:

  • Name: Fried Rice

  • Ingredients:

    • 1 cup of white rice

    • 1 gram of salt

  • Instructions:

    1. Fry the rice

    2. Add salt

Expected Outcome

new before
1) If you would like to add a recipe to CookBuddy, enter the new command including the attributes of the recipe
new after
2) After using the new command, the new recipe will be added to CookBuddy and will be displayed.

Finding recipes — find [Done by Kevin]

You can find an existing recipe with a particular attribute from CookBuddy using the find command.

Format: find [n/NAME […​]]
Format: find [ing/INGREDIENT 1, QUANTITY [; …​]]
Format: find [ins/INSTRUCTION [; …​]]

CookBuddy can find recipes from one parameter at a time.

Finding a recipe by name

You can find a recipe by its name by running find n/NAME […​].

Example: You can type find n/Ham and CookBuddy will display recipes that contain the word Ham in their name.

Expected Outcome

findName before
1) You want to find recipes that contain Ham in their name
findName after
2) After using the find n/Ham command, recipes that contain Ham in their name are displayed.

Finding a recipe by ingredient

You can find a recipe by its ingredients by running find ing/INGREDIENT […​].

Example: You can type find ing/bread and CookBuddy will display the recipes containing bread as an ingredient to you.

findIngredients before
1) You want to find recipes that contain bread in their ingredients
findIngredients after
2) After using the find ing/bread command, recipes that contain bread in their ingredients are displayed.

Finding a recipe by instructions

You can find a recipe by its instructions by running find ins/INSTRUCTION […​].

Example: You can type find ins/head and CookBuddy will display the recipes containing head in its instructions to you.

findInstructions before
1) You want to find recipes that contain head in their instructions
findInstructions after
2) After using the find ins/head command, recipes that contain head in their ingredients are displayed.

Contributions to the Developer Guide

Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project.

Finding recipes [Done by Kevin]

The following section describes how the find command is implemented as well as design considerations that were taken into account during its implementation. Some possible future improvements are also suggested to improve the functionality of the find command.

The find command is implemented in the FindCommand class.

The following activity diagram shows the possible paths CookBuddy can take when a find command is run.

FindCommandActivityDiagram
Figure 1. Activity diagram of finding recipes

Implementation

  1. When entering the find command, the user will specify one attribute to search within as well as the search terms.
    Possible attributes to search within are name (n/), ingredients (ing/) and instructions (ins/).

  2. FindCommandParser ensures that only one attribute is specified and returns a FindCommand with the relevant ContainsKeywordPredicate class.

The following sequence diagram summarizes the execution of the find command

FindCommandSequenceDiagram
Figure 2. Sequence diagram for the execution of a find command

Design Considerations

As the FindCommand class only takes in a single ContainsKeywordsPredicate object, CookBuddy can only search within a single attribute at a time.

Possible improvements

As it is currently implemented, the find command only accepts finding via one attribute at a time. A possible future improvement would enable it to search for recipes using multiple attributes. This would greatly enhance the usefulness of the find function in CookBuddy.

For example, running find n/Ham ing/toast will make CookBuddy search for recipes with Ham in its name, or toast in its ingredients.

Instructions for Manual Testing [Done by Kevin]

Given below are instructions to test the app manually.

These instructions only provide a starting point for testers to work on; testers are advised to do more exploratory testing.

Launch and Shutdown

  1. Launching CookBuddy

    1. Ensure you are using Java 11 by opening a Command Prompt / terminal and run java -version.

    2. Download the latest CookBuddy jar file here and copy it into an empty folder

    3. Launch Command Prompt / a terminal, navigate to the folder CookBuddy is in and enter java -jar CookBuddy.jar. Do not double-click CookBuddy.jar
      Expected: Shows CookBuddy’s GUI with a set of sample recipes. The window size may not be optimum.

  2. Saving window preferences

    1. Resize CookBuddy’s window to an optimum size. Move the window to a different location on the screen. Close the window.

    2. Re-launch CookBuddy by entering java -jar CookBuddy.jar in a Command Prompt / terminal.
      Expected: The most recent window size and location is retained.

  3. Exiting CookBuddy

    1. On Windows, click the Close Window button X on the top-right corner of CookBuddy’s GUI

    2. On Mac, click the Close Window button X on the top-left corner of CookBuddy’s GUI

    3. Type exit in CookBuddy’s command box and press Enter

      Expected: CookBuddy will shut down.

Adding a recipe

  1. Add a recipe with all mandatory fields present. Name (n/), Ingredients (ing/) and Instructions (ins/) are mandatory fields.

    1. Prerequisites: The recipe to be added is not present in the recipe book.

    2. Test case: new n/Eggs on Toast ing/bread, 2 slices; egg, 1 ins/toast the 2 slices of bread; scramble the eggs; put eggs on toasted bread; serve
      Expected: The Eggs on Toast recipe is added to the recipe list. Details of the newly added recipe is shown in the result pane.

  2. Add a recipe with one mandatory field missing, Instructions in this case.

    1. Test case: new n/Eggs on Toast ing/bread, 2 slices; egg, 1
      Expected: No recipe is added. An "Invalid command format" error message is shown in the result pane.

  3. Add a recipe with a missing ingredient quantity (egg is missing its quantity)

    1. Test Case: new n/Eggs on Toast ing/bread, 2 slices; egg ins/toast the 2 slices of bread; scramble the eggs; put eggs on toasted bread; serve
      Expected: No recipe is added. Error message No quantity has been provided for one or more ingredients! is shown in the result pane.

Modifying a recipe

CookBuddy should contain at least one recipe. If no recipe exists, delete the data folder and re-launch CookBuddy. The recipe book should contain two recipes, Ham Sandwich & Idiot Sandwich.
The Modify command allows changing multiple attributes in one command. For example, modify 1 n/Rice cal/250 updates both recipe 1’s name and calories.
  1. Modifying a recipe’s name

    1. Test Case: modify 1 n/Chicken Rice
      Expected: The first recipe’s name is updated to Chicken Rice.

    2. Test Case: modify 1 n/
      Expected: The first recipe’s name is not updated. Error details are shown in in result pane.

    3. Test Case: modify 1 n/!@#abc
      Expected: The first recipe’s name is not updated. Error details are shown in in result pane.

  2. Modifying a recipe’s ingredients

    1. Test Case: modify 1 ing/ing1, qty1; ing2, qty2
      Expected: The first recipe’s original ingredients should be overwritten with ing1 & ing2.

    2. Test Case: modify 1 ing/ing1, ; ing2, qty2
      Expected: The first recipe’s ingredients are not updated due to ing1 missing its quantity.

    3. Test Case: modify 1 ing/, qty1; ing2, qty2
      Expected: The first recipe’s ingredients are not updated due to ing1 missing its name.

  3. Modifying a recipe’s instructions

    1. Test Case: modify 1 ins/ins1; ins2
      Expected: The first recipe’s original instructions should be overwritten with ins1 & ins2.

    2. Test Case: modify 1 ins/
      Expected: The first recipe’s instructions should not be updated. Error details are shown in in result pane.

  4. Modifying a recipe’s calories

    1. Test Case: modify 1 cal/2000
      Expected: The first recipe’s calories should be updated to 2000 kCal.

    2. Test Case: modify 1 cal/abc
      Expected: The first recipe’s calories is not updated. Error details are shown in in result pane.

  5. Modifying a recipe’s serving size

    1. Test Case: modify 1 s/3
      Expected: The first recipe’s serving size should be updated to 3.

    2. Test Case: modify 1 s/abc
      Expected: The first recipe’s serving size is not updated. Error details are shown in in result pane.

  6. Modifying a recipe’s difficulty

    1. Test Case: modify 1 d/4
      Expected: The first recipe’s difficulty should be updated to 4 on a scale of 1 to 5.

    2. Test Case: modify 1 d/6
      Expected: The first recipe’s difficulty is not updated. Error details are shown in in result pane.

    3. Test Case: modify 1 d/abc
      Expected: The first recipe’s difficulty is not updated. Error details are shown in in result pane.

  7. Modifying a recipe’s rating

    1. Test Case: modify 1 r/5
      Expected: The first recipe’s rating should be updated to 5 stars.

    2. Test Case: modify 1 r/8
      Expected: The first recipe’s rating is not updated. Error details are shown in in result pane.

    3. Test Case: modify 1 r/abc
      Expected: The first recipe’s rating is not updated. Error details are shown in in result pane.

  8. Modifying a recipe’s tags

    1. Test Case: modify 1 t/breakfast
      Expected: The first recipe’s tags should be updated to contain one tag, breakfast.

    2. Test Case: modify 1 t/breakfast, lunch
      Expected: The first recipe’s tags should be updated to contain two tags, breakfast & lunch.

    3. Test Case: modify 1 t/
      Expected: The first recipe’s tags should be updated to contain zero tags.

Finding a recipe

  1. Finding recipes by name

    1. Prerequisite: CookBuddy contains a recipe with Ham in its name.
      Test Case: find n/Ham
      Expected: Recipes with the word Ham in their name are listed.

    2. Prerequisite: CookBuddy contains Ham Sandwich and Idiot Sandwich.
      Test Case: find n/Ham Sandwich
      Expected: Recipes whose name contains Ham or Sandwich are listed. So both Ham Sandwich and Idiot Sandwich are listed.

  2. Finding recipes by ingredient

    1. Prerequisite: CookBuddy contains a recipe with bread in its ingredients.
      Test Case: find ing/bread
      Expected: Recipes whose ingredient names contain bread are listed.

  3. Finding recipes by instruction

    1. Prerequisite: CookBuddy contains a recipe with ham in its instructions.
      Test Case: find ins/bread
      Expected: Recipes whose instructions contain ham are listed.

Marking a recipe as done / not done

CookBuddy should contain at least one recipe. If no recipe exists, delete the data folder and re-launch CookBuddy. The recipe book should contain two recipes, Ham Sandwich & Idiot Sandwich.
  1. Marking a recipe as done

    1. Test Case: done 1
      Expected: The first recipe should be marked as done.

    2. Test Case: done n (where n is larger than the list size)
      Expected: An error message is shown in the result pane prompting the user to enter a valid list index number.

    3. Test Case: done abc
      Expected: An error message is shown in the result pane prompting the user to enter a valid integer.

  2. Marking a recipe as not done

    1. Test Case: undo 1
      Expected: The first recipe should be marked as not done.

    2. Test Case: undo n (where n is larger than the list size)
      Expected: An error message is shown in the result pane prompting the user to enter a valid list index number.

    3. Test Case: undo abc
      Expected: An error message is shown in the result pane prompting the user to enter a valid integer.

Marking a recipe as a favourite / not a favourite

CookBuddy should contain at least one recipe. If no recipe exists, delete the data folder and re-launch CookBuddy. The recipe book should contain two recipes, Ham Sandwich & Idiot Sandwich.
  1. Marking a recipe as a favourite

    1. Test Case: fav 1
      Expected: The first recipe should be marked as favourite, indicated by the filled heart symbol.

    2. Test Case: fav n (where n is larger than the list size)
      Expected: An error message is shown in the result pane prompting the user to enter a valid list index number.

    3. Test Case: fav abc
      Expected: An error message is shown in the result pane prompting the user to enter a valid integer.

  2. Un-marking a recipe as a favourite

    1. Test Case: unfav 1
      Expected: The first recipe should be un-marked as favourite, indicated by the un-filled heart symbol.

    2. Test Case: unfav n (where n is larger than the list size)
      Expected: An error message is shown in the result pane prompting the user to enter a valid list index number.

    3. Test Case: unfav abc
      Expected: An error message is shown in the result pane prompting the user to enter a valid integer.

Adding a prep time to a recipe

CookBuddy should contain at least one recipe. If no recipe exists, delete the data folder and re-launch CookBuddy. The recipe book should contain two recipes, Ham Sandwich & Idiot Sandwich.
  1. Adding a prep time

    1. Test Case: time 1 00:15
      Expected: The first recipe’s prep time should be updated to 15 minutes.

    2. Test Case: time 1 00:15:30
      Expected: The first recipe’s prep time should be updated to 15 minutes and 30 seconds.

    3. Test Case: time 1 00:63
      Expected: An error message is shown in the result pane prompting the user to enter a minutes value which is < 60.

    4. Test Case: time 1 00:15:65
      Expected: Expected: An error message is shown in the result pane prompting the user to enter a seconds value which is < 60.

Deleting a recipe

  1. Deleting a recipe while all recipes are listed

    1. Prerequisites: List all recipes using the list command. Have at least one recipe in the list.

    2. Test case: delete 1
      Expected: The first recipe is deleted from the list. Details of the deleted recipe is shown in the result pane.

    3. Test case: delete 0
      Expected: No recipe is deleted. Error message "The recipe index provided is invalid" is shown in the result pane.

    4. Test case: delete n (where n is larger than the list size)
      Expected: Similar to previous.

    5. Test case: delete
      Expected: No recipe is deleted. An error message prompting the user to provide an index is shown in the result pane.

    6. Test case: delete abc
      Expected: No recipe is deleted. An error message prompting the user to provide a valid integer is shown in the result pane.

Saving data

  1. Saving CookBuddy’s recipe book to the save file.

    1. Enter any valid command that modifies data in the recipe book.

    2. A file named recipebook.json should be created in the data/ folder.

  2. Dealing with missing/corrupted data in CookBuddy’s save file

    1. Edit recipebook.json and delete any recipe’s difficulty parameter and re-launch CookBuddy.

    2. The recipe whose difficulty was deleted will have defaulted back to 0 difficulty.