-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CS2113-T16-3] Expiry Eliminator #37
base: master
Are you sure you want to change the base?
Changes from 250 commits
9a7fde3
7d0ecb7
3bf5955
a4dc818
b7822e5
397fb7e
f6754b9
b967c86
edd2f1b
89fa7aa
f34d35a
b3a3202
d28aa17
bb267d3
2aef4e8
8c0a5cb
d80e0f3
1dee2b7
8918911
406935c
53bc9c0
2e4b20c
24d12f1
03a65d2
d81f9b1
73fe43f
51aece3
4a35ae2
705949b
1c20e50
910cea3
5aaa382
24e7223
e83f97f
3611d9f
0aedd4d
cd06c81
268244e
c7ae7c0
cfb1572
1c2000b
856c171
4c261b9
48ee788
e749937
81c0e4e
fef0c70
55c2360
6a40189
a268dca
de0004a
a191fef
f797e65
fb00b70
4e27dda
8f52249
a4692e7
b5e5daf
ee4a716
bfc775e
b185f7f
8283e99
517153f
9892425
84c1cba
061c812
7550aa3
e6fd4e5
d4a19a3
1b23302
18d6b89
4de2fd7
463ab4e
2a6898a
d898c24
98627d3
4c4a742
0555d38
0eb1998
f5e837b
fa7d709
c398f2f
ed0ff3b
2321860
abe557c
d7bab59
792ba83
b4d016b
3bbb2c3
6cadf5d
20b8ed7
da3bd0c
ea631b0
cd133ae
bf63cb8
b2b3136
35d210c
c0a3e65
5b32ab3
3f6272d
1a0807d
897a415
7d2ca00
c46049f
998d8c8
f39b7c3
3e7473d
6aeef41
5205d79
86a6042
e0d0d55
eba9130
5c8bc30
8ad4320
304655b
547fde4
09f0d67
a627596
c0df5ed
733b841
a605b8c
9f08380
f6ef6f3
a193ef4
9279607
902ddcc
d227b01
bbcbdd9
dda6bad
94b1d2b
f36e258
3bc5bc1
998d756
e1c4eb6
1e60210
0c6d862
37ec750
7edea4c
a19892b
b49831b
28a3a11
6013b69
1f8d077
e6b58bc
f0642cb
129eca0
9c2d16b
95e6579
9dc6cea
99d0242
5a459c4
8caeff5
5d0b492
a706036
da0a975
2666e1a
40b6f7f
9aa83a6
51a3110
2c1dadf
c023599
5e6d888
e5086eb
1763326
6d5011f
46f074f
cfa6233
909bb79
b5647af
1501a59
4afa843
3a5d475
878eafc
6052c19
691054d
fb1ba2b
16dd514
07e6358
7c7248d
644bdb3
3d785c8
ddcfd78
6009f54
9e21f00
997ba96
d935437
df83faf
a7f0ea5
54746bf
47b8da4
853dc42
e6da899
245f223
12b9e18
ececb0d
5797b00
5603c93
feb793f
69c9a03
4421b62
79b71c6
22247ae
1766004
983255b
950eefd
bab69e7
5fbf577
788d2e8
6485fc2
0f6f12e
e77799e
7ce4d23
918b3d3
f7a7c7b
4dfce94
62178fa
a3475a6
7837517
59a9052
908ce8e
f49ff90
bc8c3e4
7b992ce
975b642
f8aca22
df49f94
54c283c
02392b1
80ad183
10ceee8
6f9ad3f
35c006e
a6b5695
8528bba
aa9b18d
8a43210
cf0d786
b258272
fc6a6f6
a7510b2
7d66f0b
f792595
7c32d43
cda11c2
af89d33
33b4835
eebcf59
a6cc584
ab52185
4348f5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,179 @@ | |
|
||
{list here sources of all reused/adapted ideas, code, documentation, and third-party libraries -- include links to the original source as well} | ||
|
||
## Design & implementation | ||
## Design | ||
|
||
{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.} | ||
### Data | ||
**API** : [Data.java](https://github.com/AY2122S1-CS2113-T16-3/tp/tree/master/src/main/java/expiryeliminator/data) | ||
|
||
![](diagrams/Data.png) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can consider adding a diagram showing the overall architecture of the application (i.e. include UI and storage components) to give readers a bigger picture. |
||
|
||
- The `Data` Component, | ||
- Stores a list of `Recipe` objects, in the form of `RecipeList` | ||
- Stores a list of `IngredientStorage`, in the form of `IngredientRepository` | ||
- Each `Recipe` has its ingredients and respective quantities stored in `IngredientQuantity` | ||
- The `Ingredient Storage` separates a specific ingredient into batches of quantities, | ||
according to the expiry date. | ||
- `Ingredient` stores the information of the ingredients, which are its name and unit, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this line be phrased better? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May I know which part is causing you confusion, so that I can phrase it properly accordingly. Thanks! |
||
e.g. Chicken and grams. | ||
|
||
### Parser | ||
|
||
This is a (partial) class diagram of the Parser component. Note that the `Parser` class in actuality is dependent on | ||
many of the classes depicted in the diagram: `SingleArgPrefix`, `MultipleArgPrefix`, `OptionalArgPrefix`, | ||
`ExpiryDateParser`, `UnitParser`, `IngredientParser`, `QuantityParser`, `RecipeParser`. The dependencies have been | ||
omitted from the diagram for simplicity. | ||
|
||
![](diagrams/ParserClassDiagram.png) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can increase the width of this diagram as the diagram is very small. Could also separate the two diagrams instead of putting it side by side There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
|
||
## Implementation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could a table of commands be added so that navigation through different commands would be easier? |
||
This section describes how the features are implemented. | ||
|
||
### List all Ingredients Feature | ||
bernardboey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The list ingredients feature is performed by `IngredientRepository`. It loops through all the different | ||
ingredient storages, and concatenates them into a string which is shown as the output list. Below is the | ||
sequence diagram for how list works. | ||
|
||
![](diagrams/List.png) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Diagram is very clean and easy to understand, good job! |
||
|
||
### List Expired Ingredients Feature | ||
|
||
The list expired ingredients feature is performed by `IngredientRepository`. It loops through all the | ||
ingredient storages. For each ingredient storage, it gets the type of ingredient being stored in that | ||
storage, and creates an empty storage for that ingredient type to store the batches of that ingredient | ||
that are expired. The code then loops through all the batches of that ingredients, and add the expired | ||
batches to the expire ingredient storage. The expired ingredient storage is converted into a string and | ||
is shown as the output. Below is the sequence diagram for how list expired ingredients works. | ||
Comment on lines
+113
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be clearer if this was in point form instead? |
||
|
||
![](diagrams/ListIngredientsExpired.png) | ||
|
||
### Delete Expired Ingredients Feature | ||
|
||
The delete expired ingredients feature is performed by the `IngredientRepository`. It loops through all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps you can consider breaking down the explanation into points instead. Would make it clearer. |
||
the ingredient storages. For each ingredient storage, it loops through all the batches of that ingredient. | ||
If the batch has expired, it adds the expiry date of that batch to an array. After it has looped though | ||
all the batches of a specific ingredient, it proceeds to remove all those ingredient batches from the | ||
repository. This process then repeats for the next type of ingredient. Below is the sequence diagram for | ||
how delete expired ingredients works. | ||
|
||
![](diagrams/DeleteExpiredIngredients.png) | ||
|
||
### View Ingredient Feature | ||
|
||
The view ingredient feature is performed by the `IngredientRepository`. It finds if the ingredient | ||
repository contains an ingredient with the same name as the user input, and return the storage of that | ||
ingredient. The storage data is represented as a string that is shown as an output. Below is the sequence | ||
diagram for how view ingredient works. | ||
|
||
![](diagrams/ViewIngredient.png) | ||
|
||
### Update Units Feature | ||
|
||
The update units feature is performed by both the `IngredientRepository` and `RecipeList`. First, it finds | ||
the ingredient storage of the ingredient and updates the units there. Then it finds the recipes which | ||
contain the ingredient and updates the units there. Below is the sequence diagram for how update unit | ||
works. | ||
|
||
![](diagrams/UpdateUnits.png) | ||
|
||
### Shopping List Feature | ||
|
||
The shopping list feature is performed by the `IngredientRepository`. It loops through all the recipes | ||
the user wants to cook and collates all the ingredients and quantities into totalIngredients. It then | ||
loops through all the ingredient storages to see if there is enough ingredients. If there isn't it adds | ||
the ingredient and respective quantity to the shopping list. It returns the shopping list as a String to | ||
be shown as the output. Below is the sequence diagram for how the shopping list feature works. | ||
|
||
![](diagrams/ShoppingList.png) | ||
|
||
### Add Recipe Feature | ||
|
||
The add recipe feature is performed by `RecipeList`. It adds a `Recipe` and its respective | ||
ingredients to the `RecipeList`. | ||
|
||
Here is the sequence diagram for how add recipe works if the correct input is given and | ||
all ingredients exist in the `Ingredient Repository`. | ||
|
||
![](diagrams/AddRecipe.png) | ||
|
||
`Recipe` checks if an ingredient exists in the `Ingredient Repository` before | ||
adding the ingredient into the `Recipe`. If it doesn't exist, `Recipe` adds | ||
the ingredient into the `Ingredient Repository` without any quantity and expiry date, | ||
and it reminds the user to update the units of the ingredients. | ||
|
||
The reason for this implementation is so that the user doesn't have to manually add the ingredients, | ||
as the ingredient has to be in the `Ingredient Repository` for the [cooked | ||
recipe feature](#cooked-recipe-feature) to work | ||
|
||
> **Note** : Here are a few cases where an error will be returned, and the `Recipe` | ||
> will not be saved. | ||
> | ||
> - the `Recipe` already exists in the `RecipeList`, | ||
> - A number less than 1 is entered for one of the quantity of the ingredients of the `Recipe`. | ||
> - Two same ingredients in one `Recipe`. | ||
|
||
<br/> | ||
|
||
### Delete Recipe Feature | ||
|
||
The delete recipe feature is performed by `RecipeList`. It deletes a `Recipe` from the `RecipeList`. | ||
|
||
Here is the sequence diagram for how delete recipe works if the `Recipe` exists in the `RecipeList`. | ||
|
||
![](diagrams/DeleteRecipe.png) | ||
|
||
> **Note** : If the `Recipe` doesn't exist in the `RecipeList`, an error will be returned. | ||
|
||
<br/> | ||
|
||
### Cooked Recipe Feature | ||
|
||
The cooked recipe feature is performed by `Recipe`. It deletes a certain quantity of ingredients in the | ||
`Ingredient Repository` based on the quantities of ingredients in the `Recipe`. | ||
|
||
Here is the sequence diagram for how cooked recipe works if the amount of ingredients in the `Ingredient Repository` | ||
is sufficient to be deducted. | ||
|
||
![](diagrams/CookedRecipe.png) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
The feature leaves the responsibility of dealing with expired ingredients to the user, and | ||
will remove ingredients starting from the earliest batch of ingredients. (ingredients that | ||
expire the soonest, including those that are already expired.) | ||
|
||
> **Note** : Here are a few cases where an error will be returned, and the quantities of the ingredients in the | ||
> `Ingredient Repository` will not be updated. | ||
> | ||
> - The `Recipe` does not exist in the `RecipeList` | ||
> - There is insufficient ingredients in the `Ingredient Repository` for the `Recipe` to be cooked. | ||
|
||
<br/> | ||
|
||
###List Recipes User Can Cook Feature | ||
bernardboey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The list recipe user can cook feature is performed by the `ListRecipeUserCanCookCommand`. | ||
It returns a list of recipes that the user can cook with the ingredients the user currently | ||
have. | ||
|
||
Here is the sequence diagram for how list recipe user can cook works | ||
|
||
![](diagrams/ListRecipesUserCanCook.png) | ||
|
||
The feature will indicate that the `Recipe` can be cooked even if some of the ingredients have | ||
expired. However, it will inform the user that there are expiring ingredients. The responsibility | ||
of dealing with expired ingredients is left to the user. | ||
|
||
The feature will inform the user if there is insufficient ingredients to cook any `Recipe` or if | ||
there is no `Recipe` in the `RecipeList`. | ||
|
||
<br/> | ||
|
||
## Product scope | ||
### Target user profile | ||
|
||
{Describe the target user profile} | ||
Young adults who are living in their own home. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can consider being more specific. e.g. young adults who cook often and needs to keep track of their ingredients. |
||
|
||
### Value proposition | ||
|
||
|
@@ -22,8 +186,22 @@ | |
|
||
|Version| As a ... | I want to ... | So that I can ...| | ||
|--------|----------|---------------|------------------| | ||
|v1.0|user|add an ingredient|record what ingredients I have| | ||
|v1.0|user|delete an ingredient|remove ingredients that I no longer have| | ||
|v1.0|user|increment quantities for a particular ingredient|record how much of that ingredient I have| | ||
|v1.0|user|decrement quantities for a particular ingredient|know how many ingredients are left| | ||
|v1.0|user|list the ingredients with quantities and expiry dates|know the ingredients I have at a glance| | ||
|v1.0|user|view the quantities for a particular ingredient|know how much of a specific ingredient I have| | ||
|v1.0|user|list ingredients expiring within the week|know which ingredients I should use up first| | ||
|v1.0|user|list ingredients that have expired already|know which ingredients to throw away| | ||
|v1.0|user|add the expiry date for a specific ingredient|record when it must be used by| | ||
|v1.0|new user|see usage instructions|refer to them when I forget how to use the application| | ||
|v2.0|user|find a to-do item by name|locate a to-do without having to go through the entire list| | ||
|v1.0|user|add a recipe and its constituent ingredients|keep track of what I want to cook| | ||
|v1.0|user|delete a recipe|retain only recipes I want| | ||
|v2.0|user|be able to indicate that I have cooked a recipe|keep my ingredient repository accurate| | ||
|v2.0|user|list recipes i can cook based on the ingredients I have|save time on checking the ingredients I have| | ||
|v2.0|user|generate a shopping list for a particular recipe/recipes|know what ingredients to buy| | ||
|v2.0|user|delete all ingredients that have expired at one go|all ingredients I keep track of are not expired| | ||
|
||
## Non-Functional Requirements | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-cayman |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@startuml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this diagram is really big maybe u could split it into one logic diagram that calls the functions in a data diagram that only has the recipe class. then add another diagram just for the data diagram. the wording is way too small on this diagram |
||
'https://plantuml.com/sequence-diagram | ||
|
||
autonumber | ||
box Logic | ||
-> Parser: parseCommand(userInput) | ||
activate Parser | ||
|
||
create AddRecipeCommand | ||
Parser -> AddRecipeCommand : AddRecipeCommand(recipe, ingredientNames, quantities) | ||
activate AddRecipeCommand | ||
|
||
return | ||
return command | ||
|
||
-> AddRecipeCommand : execute(ingredients,recipes) | ||
activate AddRecipeCommand | ||
end box | ||
|
||
box Data | ||
create Recipe | ||
AddRecipeCommand -> Recipe : Recipe(name) | ||
activate Recipe | ||
|
||
return | ||
|
||
loop all ingredients | ||
AddRecipeCommand -> Recipe : add(ingredientName, quantity, ingredients) | ||
activate Recipe | ||
create IngredientQuantity | ||
Recipe -> IngredientQuantity : IngredientQuantity(ingredientName, quantity) | ||
activate IngredientQuantity | ||
return | ||
end | ||
|
||
return | ||
|
||
AddRecipeCommand -> RecipeList : add(recipe) | ||
activate RecipeList | ||
end box | ||
|
||
return | ||
return message | ||
destroy AddRecipeCommand | ||
@enduml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you consider including some class or object diagrams to illustrate how these components work?