Certain aspects of YMFC’s code was inspired from the following member(s) IPs:
Sanjith : Referenced to develop the working mechanisms of YMFC’s storage class and save load system
Luyang : Referenced to develop the working mechanisms of YMFC’s storage class
Sze Kang : Referenced to develop the working mechanisms of YMFC’s command classes
The Architecture Diagram given above explains the high-level design of the YMFC App.
Given below is a quick overview of main components and how they interact with each other.
YMFC
(consisting of YMFC
class) is in charge of app launch and shut down.
The bulk of the app’s work is done by the following components:
UI
: The user interface of the App. It handles user interaction, namely reading user input and displaying messages.Storage
: Reads data from, and writes data to, the hard disk.
Responsible for loading and saving both recipes and ingredients.Parser
: The command parser. It interprets user inputs,
turning them into Command
objects that are executed by the app.Command
: Represents actions that the user can perform, such as adding, deleting or listing recipes and ingredients.RecipeList
and IngredientList
: These manage collections of recipes and ingredients, respectively.The sequence diagram below shows how the components interact with each other when the application is first launched.
Ui
ClassThe Ui
class deals with taking in inputs from an input stream (in this case, the user input through System.in
),
and then printing messages read-able by the user (through System.out
).
Recipe
ClassThe Recipe
class represents a singular recipe added by the user or loaded from the storage database.
A valid recipe object contains the following fields:
The formatting of how a recipe is displayed and saved is handled by this class.
RecommendedRecipe
ClassThe RecommendedRecipe
class represents a recipe to recommend to the user with relevant statistics.
A RecommendedRecipe
object contains the following:
Recipe
being recommended)SortByPercentMatch
ClassThe SortByPercentMatch
class inherits from the Java Comparator
class to overload its compare method.
This is used to allow Java methods like sort which uses this method to know how to compare two RecommendedRecipe
objects based on their percentage match attribute. The compare method is implemented such that when used to sort
a list of RecommendedRecipe
objects, they are sorted in descending order based on their percentage match attribute.
RecipeList
ClassThe RecipeList
class represents a list of recipes.
This class handles the addition, deletion and editing of recipes.
Shown below is a class diagram detailing the interaction between RecipeList
and Recipe
:
Ingredient
ClassThe Ingredient
class represents an individual ingredient added by the user or loaded from the storage database.
String Name
Ingredient(String name)
:
Ingredient
instance with the specified nameboolean equals(Ingredient ingredientToCheck)
:
Ingredient
with another Ingredient
based on their names@Override boolean equals(Object object)
:
retainAll()
and removeAll()
, allowing ingredients
to be compared based on name alone in collectionsString toString()
:
String toSaveString()
:
new n/<ingredient_name>
The formatting of how an ingredient is displayed and saved is handled by this class.
IngredientList
ClassThe IngredientList
class represents a list of ingredients.
This class handles the addition, deletion and editing of ingredients.
ArrayList<Ingredient> ingredients
: Holds a list of Ingredient
objects, representing the ingredients in the listIngredientList()
:
Initializes an empty list of ingredients.void addIngredient(Ingredient ingredient)
:
Ingredient
to the listArrayList<Ingredient> getIngredients()
:
Ingredient getIngredient(int id)
:
boolean removeIngredientByName(String name)
:
Ingredient
by nameint getCounter()
:
void sortAlphabetically()
:
Shown below is a class diagram detailing the interaction between IngredientList
and Ingredient
:
Command
ClassesThe Command
class deals with all the possible commands accepted by YMFC, with each command representing a specific
recognised user input (E.g. ListCommand
representing the command to list all the recipes in the recipeList
).
Command
base classisBye
: A flag that tracks if an exit command has been issued, following which programme should be terminated
setBye()
isBye()
execute()
: An abstract method that must be implemented by all subclasses
recipeList
for AddRecipeCommand
)Shown below is a class diagram detailing the interaction between the parent Command
class and it’s child classes:
Command
Classes)Command
subclass by passing user input through the parseCommand()
of Parser
ByeCommand
), set isBye
to trueexecute()
, performing the desired action and interacting with YMFC’s data and UI componentsCommand
ClassesCommand
class:
Command
: Each new command class extends Command
, inheriting its structure and providing a specific
implementation of the execute()
methodexecute()
: Implement execute()
to define how the command should interact with RecipeList
,
IngredientList
, Ui
, and Storage
parseCommand()
method in Parser
to recognise and instantiate the new commandCommand
Child ClassesAddCommand
ClassAddCommand
class adds a newly created Recipe object to the current RecipeList object’s ArrayList of RecipesShown below is a sequence diagram detailing how a new recipe is added using the AddCommand object,
starting from parsing the user input to the addition of the recipe to the recipeList object,
to finally printing the “recipe added” message to the User on the CLI:
EditCommand
ClassEditCommand
class finds an existing recipe in RecipeList by name, and then replaces its parameter
with the new parameters that the user inputted.Shown below is a sequence diagram detailing how an existing recipe is modified using the EditCommand object,
starting from parsing the user input to finding the exiting recipe in the RecipeList object,
to finally modifying and saving the recipe in the RecipeList:
AddIngredientCommand
ClassAddIngredientCommand
class is responsible for adding a new ingredient to IngredientList
Ingredient
object, adds it to the IngredientList
, saves the updated list to the storage, and
notifies the user of the addition through the Ui
component.ByeCommand
ClassByeCommand
class represents the command to terminate the applicationisBye
)
and displays a farewell message to the userDeleteCommand
DeleteCommand
class represents the command to delete a recipe by its name from RecipeList
RecipeList
for the recipe, removes it if found, saves the updated list to the
storage, and informs the user of the successful deletion or an error if the recipe is not foundDeleteIngredientCommand
ClassDeleteIngredientCommand
class is responsible for deleting an Ingredient
from the IngredientList
based on
its nameIngredient
, updates the Ingredientlist
in the storage, and notifies
the user about the deletion
FindCommand
ClassFindCommand
class is used to find recipes based on user’s query and optionsRecipeList
will be printed out using the
printFind()
method from the Ui
classprintEmptyFind()
will be used insteadFindIngredientCommand
ClassFindIngredientCommand
attempts to find an existing Ingredient
in IngredientList
by nameprintFindIngred()
method of the Ui
to display the matching ingredients foundprintEmptyFindIngred()
of Ui
method is called insteadHelpCommand
ClassHelpCommand
class is designed to provide the user with a list of available commands and detailed instructions
on how to use themprintHelp()
method of the Ui
to display help informationListCommand
ClassListCommand
class is designed to list all the recipes present in the RecipeList
UI
ListIngredientCommand
ClassListIngredientCommand
class is responsible for listing all the ingredients currently stored in the
IngredientList
UI
RandomCommand
ClassRandomCommand
class is designed to show the user a randomly selected recipe from their recipeListUi
RecommendCommand
ClassRecommendCommand
class selects all recipes from the RecipeList and displays those that share common
ingredients with what is found in IngredientList. The percentage of the recipe’s ingredients that are shared, as well
as the missing ingredients are also determinedUi
with their accompanying statistics, listed by descending order
of their percentage matchSortCommand
ClassSortCommand
class is designed to sort all the existing recipes in the RecipeList
SortIngredientCommand
ClassSortIngredientCommand
class is designed to sort all the existing ingredients in the IngredientList
Self-explanatory, made for parsing user’s input command. This class only consist of one public static method
parseCommand()
in order to process input commands.
The remaining private methods represent separated cases for different commands.
Shown below is a sequence diagram detailing how the Parser class interprets the user’s CLI input
and returns the appropriate command object containing the user’s input parameters.
Note: The
getXYZCommand(args)
method is used for commands that further need to extract parameters from the user’s input
beyond just the command name, such as for the sort
command which needs to extract from the input, the type of sort that
is requested. In the example of the sort command, the getXYZCommand(args)
method is called getSortCommand()
.
Storage
ClassThe Storage
class
.txt
file
saveRecipes()
method in the Storage class
saves all the created recipes into the .txt
file.txt
save files to load in past saved recipes immediately when app is launched
loadRecipes()
method in the Storage
class
loads in past saved recipes from the .txt
file when the app is first launchedThe Storage
class also saves and loads the list of user’s available ingredients to another .txt
save file.
The mechanisms with which it does so is highly similar to the 2 sequence diagrams above.
There is a main YMFCException
class that extends the Exception
class.
There are then 4 child exception classes that inherit from the YMFCException
class.
EmptyListException
:
InvalidArgumentException
:
InvalidCommandException
:
InvalidSaveLineException
:
Cooks who want to quickly search up recipes or get recipe suggestions based on their available ingredients
Cooks these days have more recipes than they know how to handle, and our product will help them store, retrieve and search through their recipes with ease. Users can also store their available inventory of ingredients. Prompts, tags and ingredients can be used to search a curated database, and even recommend recipes that contain whatever ingredients the user has on hand.
Version | As a … | I want to … | So that I can … |
---|---|---|---|
v1.0 | user | start and close the application | use it only when I need to |
v1.0 | new user | see list of available commands | refer to them when I forget how to use the application |
v1.0 | constant user | see list of all my added recipes | glance at all my recipes in one go |
v1.0 | picky user | remove recipes from database | remove recipes that do not fit my changing taste buds |
v1.0 | forgetful user | store information about my recipes in a database | have a tool to track organise my recipes |
v2.0 | heavy user | find specific recipes by name/ingredients/steps | filter through my huge list of recipes easily to find what I want |
v2.0 | unimaginative cook | get random recipe suggestions | find and cook recipes that I have not cooked recently |
v2.0 | broke college student | get recipe suggestions based on my current ingredient list | get recipes that I can currently cook with my limited ingredients |
v2.0 | user | sort my recipes alphabetically | glance through my recipes more easily |
v2.0 | busy user | sort my recipes by preparation time | find a recipe that I can cook within my current time limit |
v2.0 | picky user | edit the recipes inside my database | update and improve on my existing recipes |
v2.0 | forgetful user | store information about my ingredients in a database | have a tool to track and organise my ingredients |
v2.0 | user | remove ingredients from database | remove ingredients that I have used/expired |
v2.0 | forgetful user | find specific ingredients by name | check if I have the specific ingredient in my inventory |
v2.0 | user | sort the ingredients in my inventory list | glance through my inventory list more easily |
v2.0 | constant user | see list of all the ingredients in my inventory list | glance at all my ingredients in one go |
.txt
files need to be moved overRecipe
- A plan on cooking a meal that contains various attributes such as name, ingredients needed,
steps to take, cuisine and time taken to cookRecipeList
- The collection of Recipes added by the userIngredient
- A specific cooking item that the user currently has in their inventoryIngredientList
- The collection of Ingredients available to the user (i.e. the inventory)Here is a sample list of inputs that can be used to test the available features:
At any point in the following sequence (after the current command has fully executed), you can close YMFC and reopen it, and your database of recipes and ingredients would have been saved and loaded in fully.
help
add n/Omelette i/eggs i/salt s1/crack eggs in pan s2/add salt t/4
add n/Pasta i/pasta i/tomato paste s1/boil pasta s2/mix pasta with tomato paste c/Italian t/15
add n/Apple Juice i/apples i/sugar i/water s1/throw apples, sugar and water into a blender and blend t/2
list
sort s/name
sort s/time
find i/sugar
edit e/Pasta i/pasta i/olive oil i/garlic s1/saute garlic in oil s2/boil paste s3/add pasta to garlic and mix
random
delete n/Apple Juice
new n/eggs
new n/garlic
new n/salt
listI
sortI
findI salt
recommend
deleteI n/eggs
bye
Refer to the UserGuide for the full list of available commands, their syntax, and their expected behaviour.