Skip to content
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

Update DeleteCommand to delete by index or name #29

Merged

Conversation

cleowenxuan
Copy link
Collaborator

Fix #3
Modify the ParserUtil to include a new method called parseNameIndex. This method takes in the string argument and returns either a String name or String index to delete the contacts based on index or name.

@cleowenxuan cleowenxuan added this to the v1.2 milestone Mar 15, 2024
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 47.22222% with 19 lines in your changes are missing coverage. Please review.

Project coverage is 73.89%. Comparing base (c1e9956) to head (555d36e).
Report is 11 commits behind head on master.

Files Patch % Lines
...va/seedu/address/logic/commands/DeleteCommand.java 45.00% 9 Missing and 2 partials ⚠️
...eedu/address/logic/parser/DeleteCommandParser.java 40.00% 5 Missing and 1 partial ⚠️
...in/java/seedu/address/logic/parser/ParserUtil.java 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #29      +/-   ##
============================================
- Coverage     75.26%   73.89%   -1.37%     
- Complexity      419      445      +26     
============================================
  Files            71       74       +3     
  Lines          1338     1444     +106     
  Branches        126      147      +21     
============================================
+ Hits           1007     1067      +60     
- Misses          301      339      +38     
- Partials         30       38       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@peienlim peienlim left a comment

Choose a reason for hiding this comment

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

Other than declaration of static variables to be reused, the rest of the changes lgtm!

model.deletePerson(personToDelete);
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete)));
} else {
throw new CommandException("Person with the name \"" + targetName + "\" not found.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

For greater consistency, would it be better to abstract the String and declare it at the top of the file as a static final variable, similar to MESSAGE_DELETE_PERSON_SUCCESS?

throw new CommandException("Person with the name \"" + targetName + "\" not found.");
}
} else {
throw new CommandException("Please provide the correct index or the full name of the person!");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as the comment above, but could be declared in Messages.java like MESSAGE_INVALID_PERSON_DISPLAYED_INDEX which was used in line 51

String nameString = name.toString();
return new DeleteCommand(null, nameString);
} else {
throw new ParseException("Unexpected error occurred while parsing DeleteCommand.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as the comments above!

@@ -29,8 +30,9 @@ public class DeleteCommandTest {

@Test
public void execute_validIndexUnfilteredList_success() {
String dummyName = " ";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since dummyName is used multiple times throughout this file, it could be declared as a static variable for reuse?

Copy link
Collaborator

@peienlim peienlim left a comment

Choose a reason for hiding this comment

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

LGTM

@cleowenxuan cleowenxuan merged commit 801feda into AY2324S2-CS2103T-T11-3:master Mar 21, 2024
3 of 5 checks passed
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.

[v1.2] As a user I can delete contacts based on the name or index
2 participants