data.txt
, ensuring that user data is saved and can be retrieved when the application is relaunched.The Command classes are responsible for encapsulating the logic and parameters associated with each command in the application.
The Command classes are designed to be modular and expandable, allowing for easy addition of new commands and functionalities. The core components of the Command classes include:
execute
method, which contains the logic for performing the action associated with that command. This method is called when the parser returns the command object to the main program.The Parser feature is a crucial component of the application, responsible for interpreting and processing user input. It serves as the bridge between the user interface and the underlying logic of the application, ensuring that commands are correctly understood and executed.
The Parser feature is designed to be modular and extensible, allowing for easy addition of new commands and functionalities. The core components of the Parser feature include:
Command Classes: Each command is represented by a separate class, which encapsulates the logic and parameters associated with that command. This design allows for clear separation of concerns and makes it easy to add new commands in the future.
Parser Class: The Parser
class is responsible for parsing the user input and instantiating the appropriate command class. It uses a series of switch
statements to determine the type of command based on the input string.
Command Execution: Once the command is parsed and instantiated, it is executed by calling the execute
method on the command object. This method contains the logic for performing the action associated with the command.
Error Handling: The Parser feature includes error handling to manage invalid input and provide feedback to the user. If the input cannot be parsed or if the command is not recognized, an appropriate error message is displayed.
The following sequence diagram illustrates the interaction between the user, the Parser
, and the Command
classes during the execution of a command:
By using separate command classes, we can easily extend the functionality of the application without modifying the core parsing logic. By encapsulating the command logic within individual classes, we adhere to the Single Responsibility Principle, making the codebase easier to understand and maintain. —
The Storage feature is responsible for managing the persistence of data when the application exits. It handles the reading
and writing of data to and from data.txt
, ensuring that user data is saved and can be retrieved when the application is relaunched
The Storage feature is designed to be modular and extensible, allowing for easy addition of new data types and functionalities. The core components of the Storage feature include:
Storage
class is responsible for managing the reading and writing of data to and from data.txt
. It provides methods for loading data from the file and saving data back to the file.IngredientInventory
, ShoppingList
, RecipeManager
, and PlanPresets
. Each of these classes represents a specific type of data list and provides methods for manipulating that list.data.txt
. It ensures that the data is formatted correctly and that any errors during file operations are handled gracefully.The following sequence diagram illustrates the interaction between the Storage
class and the other key lists in the application during the loading and saving of data:
The key lists include: StockList
, LowStockList
, RecipeList
, ShoppingList
The data is stored in a text file called data.txt
in the following format:
[Shopping] <Ingredient> <Quantity> <Unit> <isPurchased>
[Stock] <Ingredient> <Quantity> <Unit> <Category>
[LowStock] <Ingredient> <Quantity>
[Recipe] <RecipeName>
[Ingredients] <Ingredient1> <Quantity1> <Unit1> <Category1> | ...
[Instructions] <Instruction1> | <Instruction2> | ...
[MealPlan] <MealPlanName>
[Breakfast] <Recipe Index>
[Lunch] <Recipe Index>
[Dinner] <Recipe Index>
[WeeklyPlan]
[MONDAY] <Plan Index>
[TUESDAY] <Plan Index>
[WEDNESDAY] <Plan Index>
[THURSDAY] <Plan Index>
[FRIDAY] <Plan Index>
[SATURDAY] <Plan Index>
[SUNDAY] <Plan Index>
The MealPlan feature is the core feature of the PantryPal application, and is responsible for the cohesion of the Recipe, ShoppingList and IngredientInventory features. A Plan instance encapsulates the planRecipes and planName attributes, which are containers for Recipe and the identifier used for searching respectively.
The MealPlan feature is designed for quick interfacing and adaptation of a user’s tangible plans.
The MealPlanManager feature holds a collection of Plan objects for, quick re-iterations of a same meal plan as well as the tangible representation of the user’s weekly schedule in weeklyPlans. It encapsulates planList, an ArrayList of Plan objects that have been created by the user, and draws from this to substantiate a weeklyPlan instance for use.
The MealPlanManager feature is designed for convenience, allowing the user to re-use a same plan for purposes of a diet, without having to painstakingly enter the details for every duplicate meal plan they are planning to add to their viewing schedule.
The following sequence diagram illustrates the interactions between the user, MealPlanManager, each relevant Plan and what they will present
Command List for MealPlanManager
AddPlan Command Sequence Diagram
AddPlanToDay Command Sequence Diagram
RemovePlan Command Sequence Diagram
RemovePlanFromDay Command Sequence Diagram
ExecutePlan Top-Level Command Sequence Diagram
ExecutePlan Lower-Level Command Sequence Diagram
The Ingredient feature represents individual ingredients in the system. Each ingredient instance encapsulates essential attributes such as name, quantity, and unit. This modular design ensures that ingredients can be easily created, modified, and retrieved when needed.
The Ingredient feature is designed for flexibility and accuracy, ensuring seamless interaction with other components like the Ingredient Inventory, Recipe, and Recipe Manager. The core components of the Ingredient feature include:
The Ingredient Inventory feature is responsible for managing a collection of ingredients, tracking their quantities, and ensuring users can monitor their stock. This feature enables users to add, update, and remove ingredients while supporting low-stock alerts.
The Ingredient Inventory feature is modular and extensible, allowing for seamless integration with features like Recipe Management and Shopping Lists. The core components of the Ingredient Inventory feature include:
The following sequence diagram illustrates the interaction between the user, the Ingredient Inventory, and the Ingredient feature during ingredient management:
The Ingredient and Ingredient Inventory features follow a modular design to ensure flexibility, scalability, and maintainability. The Single Responsibility Principle is adhered to, with the Ingredient class managing individual ingredient attributes (name, quantity, unit) and the Ingredient Inventory class handling the collection of ingredients, conversions, and stock alerts. The addition of unit conversion ensures consistency across different ingredient measurements, making it easier to track inventory. Categorization improves usability by allowing users to group and filter ingredients based on type.
The Shopping List Item feature represents individual items that need to be purchased. Each shopping list item instance encapsulates essential attributes such as ingredient name, quantity needed, and unit of measurement. This modular design ensures that shopping items can be easily created, modified, and tracked.
The Shopping List Item feature is designed for accuracy and consistency, ensuring proper integration with both the Shopping List and Ingredient Inventory features. The core components include:
The Shopping List feature is responsible for managing a collection of items that need to be purchased. It works in conjunction with the Ingredient Inventory feature to help users track items that are running low or need to be restocked.
The Shopping List feature is modular and extensible, allowing for seamless integration with the Ingredient Inventory and Recipe Management features. The core components include:
The following sequence diagram illustrates the interaction between the user, Shopping List, Shopping List Item, and Ingredient Inventory when managing shopping items:
The Shopping List Item and Shopping List features follow a modular design to ensure flexibility, scalability, and maintainability. The Single Responsibility Principle is adhered to, with the ShoppingListItem class managing individual item attributes and the ShoppingList class handling the collection of items. This clear separation makes the system easy to understand, maintain, and modify without affecting other components.
The Instruction Feature represents all the instructions in the Recipe. Each instruction instance encapsulates essential attributes such as step number and instruction content. This modular design ensures that instructions and instruction list can be easily created, modified, and retrieved when needed.
The Instruction feature is designed for flexibility and accuracy, ensuring seamless interaction with other components like the Recipe and Recipe Manager. The core components of the Ingredient feature include:
The Recipe feature represents individual recipes in the system. Each recipe instance encapsulates essential attributes such as name, instructions, and ingredients. This modular design ensures that recipes can be easily created, modified, and retrieved when needed.
The Recipe feature is designed for flexibility, accuracy and consistency, ensuring proper integration with the Recipe Manager. The core componenets of Recipe feature include:
The Recipe Management feature is responsible for managing a collection of recipes, tracking their name, ingredients and instructions. This feature enables users to add recipes, update recipe’s ingredients and instructions, and remove recipes.
The Recipe Management feature is modular and extensible, as well as maintaining accuracy, allowing it to be used seamlessly by other features. The core componenets of the Recipe Management feature include:
The following sequence diagram illustrates the interaction between the user, the Recipe Manager, the Recipe, the Ingredient, and the Instruction feature during recipe management:
The Instruction, Recipe, and Recipe Management features follow a modular design to ensure it is easy to be maintained or modified when necessary. The Single Responsibility Principle is adhered to, with Instruction manages only the recipe instructions, while Recipe acts as collection of Instruction and Ingredient, and Recipe Management acts as collection of Instruction only. By separating into smaller classes, it helps the developer understand, maintain without heavy coupling with other components.
Target user profile:
Value proposition
PantryPal addresses the common challenges faced by university students and busy individuals when it comes to meal planning, grocery shopping, and inventory management by providing an all in one solution that simplifies these tasks.
Version | As a … | I want to … | So that I can … |
---|---|---|---|
v1.0 | new user | see usage instructions | refer to them when I forget how to use the application |
v1.0 | user | create a new ingredient | keep track of items I’ve added to my pantry |
v1.0 | user | update an ingredient’s quantity | reflect changes when I buy or use ingredients |
v1.0 | user | rename an ingredient | correct mistakes or reflect updated naming |
v1.0 | user | view details of an ingredient | know exactly how much I have and what type it is |
v1.0 | user | delete an ingredient | remove unused or expired ingredients from my inventory |
v1.0 | user | set a low stock threshold for ingredients | receive alerts when I need to restock |
v1.0 | user | view all low stock items | quickly identify what needs to be replenished |
v1.0 | user | find out if an ingredient is in stock | check availability before starting a recipe |
v1.0 | budget-conscious student | auto-generate a shopping list based my current stock and planned recipes | purchase only missing ingredients |
v1.0 | busy student | manually add items to my shopping list | quickly include additional ingredients I want to have more |
v1.0 | busy student | manually remove items from my shopping list | quickly remove additional ingredients I don’t want have so much |
v1.0 | meticulous planner | view my shopping list with clearly numbered items | easily reference and manage items for later editing or removal |
v1.0 | organized shopper | edit an existing shopping list item by its index | update integredients details if my shopping needs change |
v1.0 | user | add a recipe into a list | save the recipe to be used later on |
v1.0 | user | view all the recipe I saved | choose a recipe to follow |
v1.0 | user | remove recipe easily | avoid cramping my recipe list with rarely-used recipes |
v2.0 | user | change an ingredient’s unit | work with units I prefer or understand better |
v2.0 | user | view ingredients by category | organize or filter ingredients for easier navigation |
v2.0 | user | convert the unit of an ingredient | standardize or switch between measurement systems (e.g. g to kg) |
v2.0 | cost-conscious student | mark items on my shopping list as purchased | track which items I have bought and avoid re-purchasing them |
v2.0 | user | consolidate and use all the information I have entered | have a more convenient time planning out my weeks |
Note: The following instructions serve as a basic guide for testers to validate the functionality of the program. Testers should go beyond these steps and conduct further exploratory testing.
help
help
method when starting the application.viewStock
viewStock
method when the inventory is empty.Inventory is empty.
should be displayed.viewLowStock
viewLowStock
when no ingredients are set with low stock alerts.No low stock ingredients.
should be displayed.viewRecipeList
viewRecipeList
when there are no recipes in the recipe list.There are no recipes at the moment. You can add via addRecipe
should be displayed.viewShoppingList
viewShoppingList
when there is no items in the list.Shopping list is empty
should be displayed.viewPlanList
viewPlanList
when there is no plans.No plans available
should be displayed.addNewIngredient
addNewIngredient("Sugar", 5, Unit.GRAM, Category.CONDIMENTS)
.Sugar
with quantity 5
in grams and the CONDIMENTS
category should be added to the inventory.addNewIngredient
with invalid data
addNewIngredient("", 5, Unit.GRAM, Category.CONDIMENTS)
(empty name).addNewIngredient
with negative quantity
addNewIngredient("Salt", -3, Unit.GRAM, Category.CONDIMENTS)
.increaseQuantity
increaseQuantity("Sugar", 3)
.Sugar
should be increased by 3
, making the new quantity 8
.increaseQuantity
for non-existent ingredient
increaseQuantity("Flour", 5)
.Ingredient not found
should be displayed.decreaseQuantity
decreaseQuantity("Sugar", 2)
.Sugar
should be decreased by 2
, making the new quantity 6
.decreaseQuantity
for insufficient quantity
decreaseQuantity("Sugar", 10)
.Not enough Sugar in stock.
should be displayed.decreaseQuantity
for non-existent ingredient
decreaseQuantity("Flour", 5)
.Ingredient not found
should be displayed.setAlert
setAlert("Sugar", 2)
.Sugar
should be set at the threshold of 2
.viewLowStock
viewLowStock()
.Sugar
has a quantity lower than 2
, the message Low stock: Sugar (quantity)
should be displayed.deleteIngredient
deleteIngredient("Sugar")
.Sugar
should be removed from the inventory, and the message Deleted Sugar from inventory.
should be displayed.deleteIngredient
for non-existent ingredient
deleteIngredient("Flour")
.Ingredient not found.
should be displayed.convertIngredient
convertIngredient("Sugar", Unit.KG)
.Sugar
should be converted to kilograms, and the message Sugar converted (new quantity) to KG
should be displayed.convertIngredient
for non-existent ingredient
convertIngredient("Flour", Unit.KG)
.IllegalArgumentException
with the message Ingredient not found.
viewIngredientsByCategory
viewIngredientsByCategory(Category.CONDIMENTS)
.CONDIMENTS
category should be displayed, if available.viewIngredientsByCategory
for empty category
viewIngredientsByCategory(Category.SPICES)
.No ingredients found in category: SPICES
should be displayed.addRecipe
addRecipe
good_recipe
for the recipe nameUnit
(for example, kg
)Category
(for example, DAIRY
)exit
to continueexit
to finishRecipe added successfully
should be displayed.addRecipe
with recipe name containing white space
addRecipe
recipe with space
for the recipe nameWarning: Recipe name should not contain space. Use '_' instead.
should be displayed. Users should be prompted to input the recipe name again.addRecipe
with ingredient name containing white space
addRecipe
ingredient with space
for the ingredient nameIngredient Name cannot contain spaces. Try again
should be displayed. Users should be promted to input the ingredient name again.addRecipe
with quantity not being a number
addRecipe
Invalid ingredient quantity! Try again.
should be displayed. Users should be prompted to input the quantity again.addRecipe
with non-positive quantity
addRecipe
Quantity must be greater than 0.Try again.
should be displayed. Users should be prompted to input the quantity again.addRecipe
with invalid unit
addRecipe
i love you
) for UnitInvalid ingredient unit! Try again.
should be displayed. Users should be prompted to input the unit again.addRecipe
with invalid category
addRecipe
Unit
(for example, kg
)Category
(for example, DAIRY
)exit
to continueexit
to finishInvalid category! Try again.
should be displayed. Users should be prompted to input the category again.addRecipe
with duplicate recipe
addRecipe
) with the exact steps twiceWarning: Recipe GOOD_RECIPE already exists
should be displayed. Users should be prompted to input the recipe name againviewRecipe
viewRecipe good_recipe
good_recipe
), the second section being the recipe’s ingredient and the third section being the recipe’s instructions should be displayed.viewRecipe
with non-existing recipe
viewRecipe not_existing
There is no recipe with name NOT_EXISTING
should be displayed.viewRecipeList
viewRecipeList
addShoppingItem
addShoppingItem sugar 500 g
Add 'SUGAR' to the shopping list.
should be displayed.addShoppingItem
with invalid quantity
addShoppingItem sugar -5 g
Quantity must be greater than 0
should be displayed.addShoppingItem
with duplicating item name
addShoppingItem sugar 150 g
Item 'SUGAR' already exists. Please use editShoppingItem to update the item.
should be displayed.addShoppingItem
with invalid unit
addShoppingItem sugar 500 invalid_unit
Invalid unit: invalid_unit
should be displayed.removeShoppingItem
removeShoppingItem sugar
Removed 'SUGAR' from the shopping list.
should be displayed.removeShoppingItem
with non-existent item
removeShoppingItem nonexistent_item
Item 'NONEXISTENT_ITEM' not found in the shopping list.
should be displayed.editShoppingItem
editShoppingItem 1 sugar 1000 kg
Item at index 1 updated successfully.
should be displayed.editShoppingItem
with invalid index
editShoppingItem invalid_index sugar 500 g
Invalid index provided. No item updated.
should be displayed.editShoppingItem
with invalid quantity
editShoppingItem 1 sugar -5 g
Quantity must be greater than 0
should be displayed.editShoppingItem
with existing item name
editShoppingItem 2 sugar 150 g
Ingredient name already exists. Please try again with another name.
should be displayed.markShoppingItemAsPurchased
markShoppingItemAsPurchased sugar
Marked 'SUGAR' as purchased.
should be displayed.markShoppingItemAsPurchased
with non-existent item
markShoppingItemAsPurchased nonexistent_item
Item 'NONEXISTENT_ITEM' not found in the shopping list.
should be displayed.generateShoppingList
addNewIngredient apple 500 g fruit
setAlert apple 1000
generateShoppingList
Shopping list has been auto-generated as below:
should be displayed, and the shopping list should contain sugar with quantity 500g.generateShoppingList
with no low stock items
generateShoppingList
No items need to be added to shopping list
should be displayed.viewShoppingList
with items
addShoppingItem
viewShoppingList
viewShoppingList
with purchased items
addShoppingItem
markShoppingItemAsPurchased
viewShoppingList
viewShoppingList
with empty list
viewShoppingList
Shopping list is empty.
should be displayed.addPlan
with only a whitespace after
addPlan
addPlan
with standard string
addPlan plan1
plan1
is created and can be viewedaddPlan
with special characters or characters from different language
addPlan 好\\お/πㄴ
好\\お/πㄴ
is created and can be viewedRequirements:
At least one valid addPlan
was successfully called
At least one valid addRecipe
was successfully called
A valid string (breakfast
,lunch
or dinner
) input
A addRecipeToPlan
for the same meal type was not called before
addrecipetoplan
with only a whitespace after
addrecipetoplan
addrecipetoplan
with valid inputs
addRecipeToPlan 1 1 breakfast
addRecipeToPlan
with special characters or characters from different language
addRecipeToPlan 好\\お/πㄴ
IllegalArgumentException
should be thrown and a prompt to avoid unconventional characters will be givenRequirements:
At least one valid addPlan
was successfully called
At least one valid addRecipe
was successfully called
A valid string (breakfast
,lunch
or dinner
) input
A addRecipeToPlan
for the same meal type was not called before
AddPlanToDay
with only a whitespace after
AddPlanToDay
AddPlanToDay
with valid inputs
AddPlanToDay 1 MONDAY
AddPlanToDay
with special characters or characters from different language
AddPlanToDay 2 好\\お/πㄴ
IllegalArgumentException
should be thrown and a prompt to avoid unconventional characters will be givenRequirements:
At least one valid addPlan
was successfully called
At least one valid addRecipe
was successfully called
A valid string (breakfast
,lunch
or dinner
) input
removeRecipeFromPlan
with only a whitespace after
removeRecipeFromPlan
removeRecipeFromPlan
with valid inputs
removeRecipeFromPlan 1 BREAKFAST
removeRecipeFromPlan
with special characters or characters from different language
removeRecipeFromPlan 好\\お/πㄴ
IllegalArgumentException
should be thrown and a prompt to avoid unconventional characters will be givenRequirements:
At least one valid addPlan
was successfully called
RemovePlan
with only a whitespace after
RemovePlan
RemovePlan
with valid inputs
RemovePlan 1
RemovePlan
with special characters or characters from different language
RemovePlan 好\\お/πㄴ
IllegalArgumentException
should be thrown and a prompt to avoid unconventional characters will be givenRequirements:
At least one valid addPlanToDay
was successfully called
RemovePlanFromDay
with only a whitespace after
RemovePlanFromDay
RemovePlanFromDay
with valid inputs
RemovePlanFromDay MONDAY
RemovePlan
with special characters or characters from different language
RemovePlan 好\\お/πㄴ
IllegalArgumentException
should be thrown and a prompt to avoid unconventional characters will be givenFindPlan
with no plans made or non-matching search key
FindPlan
No plans matching the search key was found
FindPlan
with matching search key
addPlan plan1
addPlan egg
addPlan lard
FindPlan l
l
are listed, preceded by their matching indicesRequirements:
At least one valid addRecipe
was called
At least one valid addIngredient
was called
At least one valid addPlanToDay
was called
execute
with insufficient ingredients in IngredientInventory
execute MONDAY
execute
with sufficient ingredients
execute TUESDAY
viewPlan
with no plans created
viewPlan 1
Invalid plan index
viewPlan
with valid index and created plan
viewPlan 1
viewDayPlan
with no plans created
viewDayPlan 1
viewDayPlan
with valid input and created plans
viewPlan 0
ViewPlanList
with no plans created
ViewPlanList
No plans available
ViewPlanList
with created plans
ViewPlanList
ViewWeekPlans
with no plans created
ViewWeekPlans
No plans available
ViewWeekPlans
with created plans
ViewWeekPlans