Skip to content

[CS2113-F11-3] PantryPal#29

Open
H-ZhanHao wants to merge 507 commits into
nus-cs2113-AY2425S2:masterfrom
AY2425S2-CS2113-F11-3:master
Open

[CS2113-F11-3] PantryPal#29
H-ZhanHao wants to merge 507 commits into
nus-cs2113-AY2425S2:masterfrom
AY2425S2-CS2113-F11-3:master

Conversation

@H-ZhanHao

Copy link
Copy Markdown

PantryPal provides NUS students a better way to manage their meals by presenting all essential information at a glance, ensuring effortless meal planning via ingredient tracking and grocery management.

@nus-se-bot nus-se-bot closed this Feb 21, 2025
@damithc damithc reopened this Feb 21, 2025
rchlai added a commit to rchlai/tp that referenced this pull request Mar 14, 2025

@sevenseasofbri sevenseasofbri left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good job team! I think the code is well structured and follows good code quality practices for the most part. I have briefly gone over and added some comments. Let me know if you have any questions.


public class Parser {

public Command parse(String input) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function is >30LOC so try to break it up into multiple functions/refactor similar portions of code into new methods.

return new RemovePlan(index);
case "addRecipe":
return new AddRecipe();
case "viewRecipe": //Add error handling for empty recipe field

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid writing comments like they are notes to the programmer themselves.

import java.util.Map;
import java.util.Scanner;

public class IngredientInventory {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all functions in this class, the method header comments need to be of the following form:

From java coding standard: In method header comments, the first sentence should start in the form Returns ..., Sends ..., Adds ... etc. (not Return or Returning etc.).

It is also better if you write them JavaDoc style.

}
}

public static void main(String[] args) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also a long function, consider breaking it into parts/refactoring relevant code.

Comment on lines +16 to +36
/*
*
* @param planIndex refers to the plan slot in a preset
*/

/*
public void AddPlanToCalendar(int planIndex){
plans.add(planPresets.get(planIndex));
}
*/

/*
*
* @param planIndex refers to the plan in this calendar
*/

/*
public void RemovePlanFromCalendar(int planIndex){
plans.remove(planIndex);
}
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid commenting out dead code. Remove if it is not needed.

public class Calendar {
String userName;
int selectedPlan;
//ArrayList<MealPlan> plans;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid commenting out dead code. Remove if it is not needed.


@Override
public boolean equals(Object obj) {
//Return True if 2 object has the same step number

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Return True if 2 object has the same step number
// Return True if 2 object has the same step number


public void editRecipe(String command) {

// Splitting into parts

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment, i think it is already clear from the code.

Comment on lines +21 to +35

for (Map.Entry<String, Double> entry : alerts.entrySet()) {
String ingredientName = entry.getKey();
double threshold = entry.getValue();

// Retrieve the ingredient details from the inventory
Ingredient ingredient = ingredients.get(ingredientName);
if (ingredient != null && ingredient.getQuantity() < threshold) {
double required = threshold - ingredient.getQuantity();

// Update existing item if present; if not, add a new item.
boolean updated = shoppingList.updateItem(ingredientName, required, ingredient.getUnit());
if (!updated) {
shoppingList.addItem(new ShoppingListItem(ingredientName, required, ingredient.getUnit()));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3-levels of indentation, consider refactoring internal levels .

import java.util.ArrayList;
import java.util.List;

public class ShoppingList {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly for this class,

In method header comments, the first sentence should start in the form Returns ..., Sends ..., Adds ... etc. (not Return or Returning etc.)

Comment thread docs/DeveloperGuide.md Outdated

4. **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.

# Sequence Diagram

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entity should have a : beside its name

Comment thread docs/DeveloperGuide.md
- **Unit Management**: Ensures valid unit selection and provides functionality for unit conversion.


## Ingredient Inventory Feature

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each class section should follow the same format/structure

Comment thread docs/DeveloperGuide.md Outdated
- **Deleting Ingredients**: Users can remove ingredients from the inventory, ensuring accurate stock representation.
- **Low-Stock Alerts**: The system supports configurable alerts to notify users when ingredients are running low.

### Sequence Diagram

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Font size should be consistent too. Nevertheless, good details overall! Covers dependencies and core functionalities

@ashleyang2001 ashleyang2001 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, this is an awesome first draft!

Comment thread docs/DeveloperGuide.md
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:
1. **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.

2. **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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to explain how parser works based on the input

Comment thread docs/DeveloperGuide.md
### Sequence Diagram
The following sequence diagram illustrates the interaction between the user, the Ingredient Inventory, and the
Ingredient feature during ingredient management:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to explain how each command interact with other classes

@jyukuan jyukuan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job but still can be improved

Comment thread docs/DeveloperGuide.md
3. **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.

4. **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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to add some sample code.

Comment thread docs/DeveloperGuide.md
## Sequence Diagram
The following sequence diagram illustrates the interaction between the user, the Ingredient Inventory, and the
Ingredient feature during ingredient management:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to make the larger difference between all the feature titles, for now it is hard to read.

Comment thread docs/DeveloperGuide.md
The following sequence diagram illustrates the interaction between the user, the `Parser`, and the `Command` classes during the execution of a command:

<img src="img_1.png" alt="drawing" style="width:900px;"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this diagram, here is no return 'dot' line and activation bar

Comment thread docs/DeveloperGuide.md
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`
<img src="img_3.png" alt="drawing" style="width:1000px;"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sequence diagram, the return 'dot' line is necessary, and it is better to regular the input format.

@xmtan1 xmtan1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the long lines of text, I think this DG was quite comprehensive!

Comment thread docs/DeveloperGuide.md Outdated

# Class Diagram
<img src="img_2.png" alt="drawing" style="width:1500px;"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the class diagram, I think it would be best to omit the names of the parameters in the class methods as the class diagram is currently quite small and hard to read..

e.g. +task(String name, Ingredient ingredient) --> +task(String, Ingredient)

Comment thread docs/DeveloperGuide.md
## Instructions for manual testing

{Give instructions on how to do a manual product testing e.g., how to load sample data to be used for testing}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a short description of what your program does?

Comment thread docs/DeveloperGuide.md
- **Add Plan**: Instantiates a new Meal Plan instance with a name optionally keyed by the user
- **Remove Plan**: Removes a plan from the currently created preset
- **Add recipe to plan**: Facilitates the procedure of adding a recipe to the indicated meal plan as decided by the user
- **Remove recipe from plan**: Facilitates the procedure of removing a recipe from the indicated meal plan as decided by the user

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add a diagram here to break up the long lines of text? For example for each feature I think it would be better to add a diagram for the core functionalities with boxes and arrows. Description of each functionality is self explanatory from the name and doesn't need to be explicity listed in my opinion.

Comment thread docs/DeveloperGuide.md Outdated
The following sequence diagram illustrates the interaction between the user, the Ingredient Inventory, and the
Ingredient feature during ingredient management:

<img src="img_4.png" alt="drawing" style="width:500px;"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For each method call, I think it would be good to add a dotted arrow back to caller class if the method returns something

Comment thread docs/DeveloperGuide.md
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:
1. **Storage Class**: The `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.
2. **Data Classes**: The Storage feature interacts with various data classes, such as `IngredientInventory`, `ShoppingList`, `RecipeManager`, and `PlanPresets`. Each of these classes represents a specific type of data list and provides methods for manipulating that list.
3. **File Handling**: The Storage feature uses file handling techniques to read and write data to `data.txt`. It ensures that the data is formatted correctly and that any errors during file operations are handled gracefully.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could provide some explanation or example of error handling (e.g. throwing exception)?

Comment thread docs/DeveloperGuide.md
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:
1. **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.
2. **Command Types**: Each command inherits from a specific command type, which is used to identify the command's functionality group. This allows for better organization and management of commands within the application.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the guide could clarify what these command types are (e.g. abstract classes/interfaces)? A brief list or example might help.

Comment thread docs/img_1.png Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the lifelines of the command objects (RecipeCommand, MealPlanCommand, etc.) continue after execute(...) to show that the object might still exist or interact with other components later?

Comment thread docs/img_1.png Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be return arrows from the execute(...) methods back to the Parser or User lifelines? It might help show what kind of response or result is returned after command execution.

srfl0 and others added 30 commits April 8, 2025 04:48
MealPlan commands naming refresh
* commit '9925f1542e215247092bce50aca65f469a2d46de':
  Rename function removePlanFromList to align with matching user input
  Fix: Gradle Coding Style Issues
  Add JavaDoc to Parser, Storage, UI
  Fix EXPECTED.txt
  Update for EXPECTED.txt
  Add JUnit Tests
  Update PantryPal.java: Main class is more OOP
  Add to commit for upstream pull
  Add on merge fixes
  Add bugfix attempts
Added Product Description in TP ReadME
Sequence diagram addition for MealPlan
Bug Fix: Add Meat into category

Storage Bug Fix: Add exception handling for illegal arguments
Update UG: Add Meal Plan Commands
Update UG: update command summary and added missing findplan command
added captions for meal plan sequence diagram to provide context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.