Skip to content

Commit

Permalink
Merge pull request #210 from teoks0199/branch-1.4-bugfix
Browse files Browse the repository at this point in the history
Fix index error message bug for view-stall and view-item
samuelmui8 authored Nov 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents f1d01b0 + 2320a9c commit b78cb88
Showing 7 changed files with 86 additions and 29 deletions.
4 changes: 2 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
@@ -218,7 +218,7 @@ The following activity diagram summarizes what happens when a user executes a ne

_{more aspects and alternatives to be added}_

### Find Item feature
### Find-by-item feature

#### Implementation

@@ -228,7 +228,7 @@ The following sequence diagram shows how the find item operation works:

![FindItemSequenceDiagram](images/FindItemSequenceDiagram.png)

The `ItemsContainKeywordsPredicate` is used to filter the list of stalls in FoodNotes. It is created with a list of keywords, and it checks if the menu items of a stall contains any of the keywords.
The `MenuContainsKeywordsPredicate` is used to filter the list of stalls in FoodNotes. It is created with a list of keywords, and it checks if the menu items of a stall contains any of the keywords.

* **Alternative 1 (current choice):** Allows the user to search for stalls containing any of the keywords.
* Pros: Users can search for multiple items at once, for example they can look for stalls that sell either "chicken" or "apple".
47 changes: 38 additions & 9 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@ title: User Guide
- 4.1 [General](#4.1-general)
* 4.1.1 [Viewing help :`help`](#4.1.1-viewing-help)
* 4.1.2 [Exiting from the application :`exit`](#4.1.2-exiting-from-the-application)
- 4.2 [Stall Management](#4.2-stall-management)
* 4.1.3 [Clearing the FoodNotes database :`clear`](#4.1.3-clearing-foodnotes)
- 4.2 [Stall Management](#4.2-stall-management)
* 4.2.1 [Listing all stalls :`list`](#4.2.1-listing-all-stalls)
* 4.2.2 [Viewing a stall :`view-stall`](#4.2.2-viewing-a-stall)
* 4.2.3 [Adding a stall :`add-stall`](#4.2.3-adding-a-stall)
@@ -223,7 +224,7 @@ Outcome:

</div>

### 4.1.2 Exiting from the application: `exit` <a id="4.1.2-exiting-from-the-application"></a>
### 4.1.2 Exiting from the application: `exit` <a id="4.1.2-exiting-from-the-application"></a>

You can use this command to exit **FoodNotes**.

@@ -247,6 +248,33 @@ Outcome:

The **FoodNotes** application window is now closed.

### 4.1.3 Clearing the FoodNotes database: `clear` <a id="4.1.3-clearing-foodnotes"></a>

You can use this command to clear the database in **FoodNotes**.

<div markdown="block" class="alert alert-info">

**:warning: This command will permanently delete all data stored in FoodNotes. You should make a backup of `addressbook.json` if you still want to keep your old data.**

</div>

**Format:**

`clear`

**Example:**

In this example, you want to clear all data stored in **FoodNotes**.

<div markdown="block" class="alert alert-white">

Exiting the application:

Type `clear` into the *Command Box* and press `Enter` to execute.

Outcome:

The **FoodNotes** database is now empty.

----
## 4.2 Stall Management <a id="4.2-stall-management"></a>
@@ -753,14 +781,14 @@ Outcome:

# 5. Glossary <a id="5-glossary"></a>

| Term | Explanation |
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| **FoodNotes** | Can refer to name of the application as a whole or to the app’s storage file.<br> |
| **Stalls** | Refers to the name of the food stall.<br> |
| **Item** | Refers to a specific food item. <br> |
| **CLI** | A Command Line Interface (CLI) is a text-based user interface that allows users to type text commands instructing the program to do specific tasks. |
| Term | Explanation |
|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **FoodNotes** | Can refer to name of the application as a whole or to the app’s storage file.<br> |
| **Stalls** | Refers to the name of the food stall.<br> |
| **Item** | Refers to a specific food item. <br> |
| **CLI** | A Command Line Interface (CLI) is a text-based user interface that allows users to type text commands instructing the program to do specific tasks. |
| **GUI** | A Graphical User Interface (GUI) is a form of user interface that allows users to interact with the program through graphical icons instead of text-based user interfaces. |
| **Absolute Path** | The complete details needed to locate a file or folder, starting from the root element. |


--------------------------
# 6. Command summary <a id="6-command-summary"></a>
@@ -771,6 +799,7 @@ Outcome:
|-----------|------------------|
| **Help** | `help` |
| **Exit** | `exit` |
| **Clear** | `clear` |

## 6.2 Stall Management Commands <a id="62-stall-management-summary"></a>

35 changes: 29 additions & 6 deletions docs/team/teoks0199.md
Original file line number Diff line number Diff line change
@@ -9,20 +9,43 @@ FoodNotes is a desktop address book application used to record reviews on food s

Given below are my contributions to the project.

* **New Feature**: TO BE ADDED
* What it does:
* Justification:
* Highlights:
* Credits:
* **New Feature**: Added the ability to edit stalls and menu items in FoodNotes.
* What it does: Allows the user to edit the details of a stall or menu item.
* Justification: This feature improves the product significantly because it allows the user to correct any mistakes made when adding a stall or menu item, or even update them with new information, for example if the price of a menu item has increased.
* Highlights: This enhancement affects existing commands and commands to be added in the future as any change to the fields of a stall or item will change how it is edited. It required an in-depth analysis of design alternatives, for example how to handle editing reviews if they don't already exist, as it is not compulsory for stalls or items to have reviews in FoodNotes.
* Credits: The ability to have optional parameters while editing was adapted from the `EditCommand` class in the original AB3.

* **New Feature**: Added the ability to find stalls in FoodNotes.
* What it does: Allows the user to find stalls by name, location or menu items.
* Justification: This feature improves the product significantly because it allows the user to find stalls that they are looking for easily, for example if they want to find a stall that sells a particular dish.
* Highlights: This enhancement required the creation of new predicate classes such as `MenuContainsKeywordsPredicate` and `LocationContainsKeywordsPredicate` to handle the filtering of different types of search queries.
* Credits: The ability to find by multiple keywords was adapted from the `FindCommand` class in the original AB3.

* **Code contributed**:
* [RepoSense link](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=teoks0199&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=docs~functional-code~test-code&since=2023-09-22&tabOpen=true&tabType=authorship&tabAuthor=teoks0199&tabRepo=AY2324S1-CS2103T-W10-4%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=docs~functional-code~test-code&authorshipIsBinaryFileTypeChecked=false&authorshipIsIgnoredFilesChecked=false)

* **Contributions to team-based tasks**:
* Refactored `Person` from the original AB3 into `Stall` for FoodNotes. This was challenging to do at the beginning as I had to remove unnecessary fields and methods, and add new ones to suit the needs of FoodNotes. Every command, even simple ones like adding, had to be refactored for the `Stall` class. I also had to change all existing tests to suit the new `Stall` class.

* **Project management**:
* Released v1.3 along with the jar file on GitHub.

* **Enhancements to existing features**:
* Refactored `AddCommand` from AB3 to `AddStallCommand` for FoodNotes.
* Refactored `DeleteCommand` from AB3 to `DeleteStallCommand` for FoodNotes.

* **Documentation**:
* User Guide:
* Added documentation for item management features in section 4.5 of the UG.
* Added command summary for all features in section 6 of the UG.
* Developer Guide:
* Added implementation details of the `find-by-item` feature.
* Added `FindItemSequenceDiagram`.
* Updated UML diagrams for `ArchitectureSequenceDiagram`, `CommitActivityDiagram`, `LogicClassDiagram`, `ParserClasses`, `StorageClassDiagram`, `UiClassDiagram`.

* **Community**:
* PRs reviewed (with non-trivial review comments): [#60](https://github.com/AY2324S1-CS2103T-W10-4/tp/pull/60), [#63](https://github.com/AY2324S1-CS2103T-W10-4/tp/pull/63), [#72](https://github.com/AY2324S1-CS2103T-W10-4/tp/pull/72), [#101](https://github.com/AY2324S1-CS2103T-W10-4/tp/pull/101)
* Reported bugs and suggestions for other teams in the class (examples: [#1](https://github.com/teoks0199/ped/issues/1), [#2](https://github.com/teoks0199/ped/issues/2), [#3](https://github.com/teoks0199/ped/issues/4), [#4](https://github.com/teoks0199/ped/issues/5), [#5](https://github.com/teoks0199/ped/issues/7), [#6](https://github.com/teoks0199/ped/issues/9))
* Some parts of Storage, such as `JsonAdaptedStall` and `JsonAdaptedItem`, were written by me. My teammates pulled my implementation from my forked repo before committing to the main repo.


* **Tools**:
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
public class ClearCommand extends Command {

public static final String COMMAND_WORD = "clear";
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";
public static final String MESSAGE_SUCCESS = "FoodNotes database has been cleared!";


@Override
Original file line number Diff line number Diff line change
@@ -29,15 +29,17 @@ public ViewItemCommand parse(String args) throws ParseException {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewItemCommand.MESSAGE_USAGE));
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_STALL, PREFIX_ITEM);
Index stallIndex;
Index itemIndex;
try {
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_STALL, PREFIX_ITEM);
Index stallIndex = ParserUtil.parseStallIndex(argMultimap.getValue(PREFIX_STALL).get());
Index itemIndex = ParserUtil.parseItemIndex(argMultimap.getValue(PREFIX_ITEM).get());
return new ViewItemCommand(stallIndex, itemIndex);
stallIndex = ParserUtil.parseStallIndex(argMultimap.getValue(PREFIX_STALL).get());
itemIndex = ParserUtil.parseItemIndex(argMultimap.getValue(PREFIX_ITEM).get());
} catch (ParseException pe) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewItemCommand.MESSAGE_USAGE), pe);
String.format(pe.getMessage(), ViewItemCommand.MESSAGE_USAGE), pe);
}
return new ViewItemCommand(stallIndex, itemIndex);
}

/**
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.logic.parser;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_INVALID_STALL_DISPLAYED_INDEX;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ITEM;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STALL;

@@ -28,14 +29,16 @@ public ViewStallCommand parse(String args) throws ParseException {
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewStallCommand.MESSAGE_USAGE));
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_STALL, PREFIX_ITEM);
Index index;
try {
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_STALL, PREFIX_ITEM);
Index index = ParserUtil.parseStallIndex(argMultimap.getValue(PREFIX_STALL).get());
return new ViewStallCommand(index);
index = ParserUtil.parseStallIndex(argMultimap.getValue(PREFIX_STALL).get());
} catch (ParseException pe) {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewStallCommand.MESSAGE_USAGE), pe);
String.format(MESSAGE_INVALID_STALL_DISPLAYED_INDEX, ViewStallCommand.MESSAGE_USAGE), pe);
}
return new ViewStallCommand(index);
}

/**
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package seedu.address.logic.parser;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_INVALID_STALL_DISPLAYED_INDEX;
import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STALL;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
@@ -24,7 +24,7 @@ public void parse_validArgs_returnsViewStallCommand() {
@Test
public void parse_invalidArgs_throwsParseException() {
String userInput = PREAMBLE_WHITESPACE + " " + PREFIX_STALL + "a";
assertParseFailure(parser, userInput, String.format(MESSAGE_INVALID_COMMAND_FORMAT,
assertParseFailure(parser, userInput, String.format(MESSAGE_INVALID_STALL_DISPLAYED_INDEX,
ViewStallCommand.MESSAGE_USAGE));
}
}

0 comments on commit b78cb88

Please sign in to comment.