Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AY2324S1-CS2103T-W16-1/tp
Browse files Browse the repository at this point in the history
…into improve-dg-find
  • Loading branch information
Nixx162 committed Oct 27, 2023
2 parents 3ce0132 + c165e7b commit aebdfa4
Show file tree
Hide file tree
Showing 28 changed files with 569 additions and 124 deletions.
61 changes: 34 additions & 27 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pageNav: 3
---

# AB-3 Developer Guide
# KeepInTouch Developer Guide

<!-- * Table of Contents -->
<page-nav-print />
Expand Down Expand Up @@ -113,6 +113,11 @@ Here are the other classes in `Logic` (omitted from the class diagram above) tha
How the parsing works:
* When called upon to parse a user command, the `AddressBookParser` class creates an `XYZCommandParser` (`XYZ` is a placeholder for the specific command name e.g., `AddCommandParser`) which uses the other classes shown above to parse the user command and create a `XYZCommand` object (e.g., `AddCommand`) which the `AddressBookParser` returns back as a `Command` object.
* All `XYZCommandParser` classes (e.g., `AddCommandParser`, `DeleteCommandParser`, ...) inherit from the `Parser` interface so that they can be treated similarly where possible e.g, during testing.
* Some commands contains secondary command, like `add contact`, `add note` and `add event`.
* - In this case, the primary command parser (in the example it is `AddCommand`) will check the secondary command word and use the correspond secondary command parser (like `AddPersonCommandParser`, `AddEventCommandParser` and `AddNoteCommandParser`) to continue parsing the command.
* The parser will turn the arguments in the command from raw `String` into corresponding Object. During this process, the parser also needs to check whether the arguments are valid or not.
* - The parsing method for each types of arguments are mainly in `ParserUtil.java`
* If the command is correct in format, the parser will then return a Command Object for the execution of the command.

### Model component
**API** : [`Model.java`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/model/Model.java)
Expand Down Expand Up @@ -297,18 +302,21 @@ _{Explain here how the data archiving feature will be implemented}_

Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unlikely to have) - `*`

| Priority | As a …​ | I want to …​ | So that I can…​ |
|----------|--------------------------------------------|------------------------------|------------------------------------------------------------------------|
| `* * *` | new user | get a list of the commands | know how to use the commands and their parameters |
| `* * *` | user | add a new contact | record one person's phone number and email address |
| `* * *` | user | delete a contact | remove a contact (by name) that I do not need |
| `* * *` | user | view all contact | easily see and know what contacts are currently stored in the application in one place |
| `* *` | user | view all notes | easily see and know what notes are currently stored in the application in one place |
| `* *` | user | add notes to a contact | record additional information about that contact in the notes |
| `* *` | user | delete notes to a contact | remove additional information that are no longer needed about that contact in the notes |
| `* *` | user who has some event to do | add an event | record an event with start time and also end time, location and any additional information like what to do during the event |
| `* *` | user who has/had some event to do | delete an event | remove an event after it is obsolete, cancelled or no longer needed to be recorded |
| `* * *` | user who finishes using the application | exit the program | exit the program normally while ensuring all my data is currectly saved |
| Priority | As a …​ | I want to …​ | So that I can…​ |
|----------|--------------------------------------------|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| `* * *` | new user | get a list of the commands | know how to use the commands and their parameters |
| `* * *` | user | add a new contact | record one person's phone number and email address |
| `* * *` | user | delete a contact | remove a contact (by name) that I do not need |
| `* * *` | user | view all contact | easily see and know what contacts are currently stored in the application in one place |
| `* *` | user | view all notes | easily see and know what notes are currently stored in the application in one place |
| `* *` | user | add notes to a contact | record additional information about that contact in the notes |
| `* *` | user | delete notes to a contact | remove additional information that are no longer needed about that contact in the notes |
| `* *` | user who has some event to do | add an event | record an event with start time and also end time, location and any additional information like what to do during the event |
| `* *` | user who has/had some event to do | delete an event | remove an event after it is obsolete, cancelled or no longer needed to be recorded |
| `* *` | tidy user | tag a contact with a label | keep my contacts oraganised and categorised |
| `* *` | tidy user | delete a tag from a contact | remove tags that are no longer relevant |
| `* *` | tidy user | edit a tag from a contact | edit tags in a contact that needs to be changed |
| `* * *` | user who finishes using the application | exit the program | exit the program normally while ensuring all my data is currectly saved |

*{More to be added}*

Expand Down Expand Up @@ -356,8 +364,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

* 1a. User inputs a contact that does not exist.

* 1a1. KeepInTouch shows a message indicating the non-existent contact.

* 1a1. KeepInTouch shows a message indicating that the contact cannot be found.
Use case ends.

* 2a. The contact list is empty.
Expand Down Expand Up @@ -400,12 +407,12 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

Use case ends.

**Use case: UC06 - Add notes to a contact**
**Use case: UC06 - Add a note to a contact**

**MSS**

1. User requests to add notes to a contact.
2. KeepInTouch adds the notes to the contact.
1. User requests to add a note to a contact.
2. KeepInTouch adds the note to the contact.

Use case ends.

Expand All @@ -419,16 +426,16 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

* 1b. User inputs a contact that does not exist.

* 1b1. KeepInTouch shows a message indicating the non-existent contact.
* 1b1. KeepInTouch shows a message indicating that the contact cannot be found.

Use case resumes at step 1.

**Use case: UC07 - Delete notes from a contact**
**Use case: UC07 - Delete a note from a contact**

**MSS**

1. User requests to delete notes from a contact.
2. KeepInTouch deletes the notes from the contact.
1. User requests to delete a note from a contact.
2. KeepInTouch deletes the note from the contact.

Use case ends.

Expand All @@ -442,14 +449,14 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

* 1b. User inputs a contact that does not exist.

* 1b1. KeepInTouch shows a message indicating the non-existent contact.
* 1b1. KeepInTouch shows a message indicating that the contact cannot be found.

Use case ends.

* 1c. User inputs notes that does not exist.

* 1c1. KeepInTouch shows a message indicating the non-existent notes.
* 1c. User inputs a note that does not exist.

* 1c1. KeepInTouch shows a message indicating that the note cannot be found.

Use case ends.

**Use case: UC08 - Add an event**
Expand Down Expand Up @@ -488,7 +495,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

* 1b. User inputs an event that does not exist.

* 1b1. KeepInTouch shows a message indicating the non-existent event.
* 1b1. KeepInTouch shows a message indicating that the event cannot be found.

Use case ends.

Expand Down
5 changes: 2 additions & 3 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ Format: `help`

Adds a person to the contact list.

Format: `add contact -n NAME [-p PHONE_NUMBER] [-a ADDRESS] [-e EMAIL]`
Format: `add contact -n NAME -p PHONE_NUMBER -a ADDRESS -e EMAIL`

<box type="tip" seamless>

</box>

Examples:
* `add contact -n Aaron -p 12345678 -a Baker Street 12 -e [email protected]`
* `add contact -n Daniel -p 87654321 -e [email protected]`

### Listing all persons : `list contact`

Expand Down Expand Up @@ -219,7 +218,7 @@ _No known issues at the moment_

Action | Format, Examples
-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------
**Add Contact** | `add contact -n NAME [-p PHONE_NUMBER] [-a ADDRESS] [-e EMAIL]` <br> e.g., `add contact -n Aaron -p 12345678 -a Baker Street 12 -e [email protected]`
**Add Contact** | `add contact -n NAME -p PHONE_NUMBER -a ADDRESS -e EMAIL` <br> e.g., `add contact -n Aaron -p 12345678 -a Baker Street 12 -e [email protected]`
**Delete Contact** | `delete contact NAME`<br> e.g., `delete contact Aaron`
**List Contact** | `list contact`
**Add Note** | `add note -n NAME -t NOTE_TITLE -c NOTE_CONTENT` <br> e.g., `add note -n Daniel -t Open Position -e Applications for SWE full-time positions will open soon`
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class Messages {

public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
public static final String MESSAGE_INVALID_DATETIME_FORMAT = "Invalid date time format! \n%1$s";
public static final String MESSAGE_INVALID_INTEGER_ARGUMENT =
"The provided argument is not a valid integer! \n%1$s";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.event.Event;
import seedu.address.model.person.ContactID;
import seedu.address.model.person.Person;

/**
Expand All @@ -14,20 +15,20 @@ public class AddEventCommand extends AddCommand {

public static final String SECONDARY_COMMAND_WORD = "event";
public static final String MESSAGE_SUCCESS = "New event added: ";
public static final String MESSAGE_PERSON_NOT_FOUND = "Can not find the target contact with ID: ";
public static final String MESSAGE_CONTACT_NOT_FOUND = "Can not find the target contact with ID: ";

public static final String MESSAGE_USAGE = COMMAND_WORD + " " + SECONDARY_COMMAND_WORD
+ ": Adds an event to a contact.\n"
+ "Usage: add event -n CONTACT_NAME -en EVENT_NAME -st "
+ "START_TIME [-et END_TIME] [-loc LOCATION] [-i INFORMATION]";

private final Event toAdd;
private final int contactId;
private final ContactID contactId;

/**
* Creates an AddEventCommand to add the specified {@code Event}
*/
public AddEventCommand(int contactId, Event event) {
public AddEventCommand(ContactID contactId, Event event) {
requireNonNull(event);
this.contactId = contactId;
this.toAdd = event;
Expand All @@ -38,7 +39,7 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
Person person = model.findPersonByUserFriendlyId(this.contactId);
if (person == null) {
throw new CommandException(MESSAGE_PERSON_NOT_FOUND + this.contactId);
throw new CommandException(MESSAGE_CONTACT_NOT_FOUND + this.contactId.getId());
}
person.addEvent(this.toAdd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.note.Note;
import seedu.address.model.person.ContactID;
import seedu.address.model.person.Person;

/**
Expand Down Expand Up @@ -35,7 +36,7 @@ public AddNoteCommand(int contactId, Note note) {
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
Person person = model.findPersonByUserFriendlyId(this.contactId);
Person person = model.findPersonByUserFriendlyId(ContactID.fromInt(this.contactId));
if (person == null) {
throw new CommandException(MESSAGE_PERSON_NOT_FOUND + this.contactId);
}
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/seedu/address/logic/commands/DeleteEventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.event.Event;
import seedu.address.model.event.EventID;
import seedu.address.model.person.ContactID;
import seedu.address.model.person.Person;

/**
Expand All @@ -14,17 +17,17 @@ public class DeleteEventCommand extends DeleteCommand {
public static final String SECONDARY_COMMAND_WORD = "event";
public static final String MESSAGE_USAGE = COMMAND_WORD + " "
+ SECONDARY_COMMAND_WORD + ": Deletes an event from a contact.\n"
+ "Usage: delete event -n CONTACT_NAME -en EVENT_NAME";
+ "Usage: delete event -id CONTACT_ID -eid EVENT_ID";
public static final String MESSAGE_PERSON_NOT_FOUND = "Can not find the target contact with ID: ";
public static final String MESSAGE_SUCCESS = "Successfully deleted event: ";
public static final String MESSAGE_EVENT_NOT_FOUND = "Event not found: ID = ";

private final int eventIdToDelete;
private final int contactId;
private final EventID eventIdToDelete;
private final ContactID contactId;
/**
* Creates an DeleteEventCommand to delete the specified {@code Event}
*/
public DeleteEventCommand(int contactId, int eventIdToDelete) {
public DeleteEventCommand(ContactID contactId, EventID eventIdToDelete) {
this.contactId = contactId;
this.eventIdToDelete = eventIdToDelete;
}
Expand All @@ -36,11 +39,11 @@ public CommandResult execute(Model model) throws CommandException {
if (person == null) {
throw new CommandException(MESSAGE_PERSON_NOT_FOUND + this.contactId);
}
boolean success = person.removeEventByUserFriendlyId(this.eventIdToDelete);
if (!success) {
Event deletedEvent = person.removeEventByUserFriendlyId(this.eventIdToDelete);
if (deletedEvent == null) {
throw new CommandException(MESSAGE_EVENT_NOT_FOUND + this.eventIdToDelete);
}

return new CommandResult(MESSAGE_SUCCESS + this.eventIdToDelete);
return new CommandResult(MESSAGE_SUCCESS + this.eventIdToDelete + ". " + deletedEvent.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.ContactID;
import seedu.address.model.person.Person;

/**
Expand Down Expand Up @@ -32,7 +33,7 @@ public DeleteNoteCommand(int contactId, int noteIdToDelete) {
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
Person person = model.findPersonByUserFriendlyId(this.contactId);
Person person = model.findPersonByUserFriendlyId(ContactID.fromInt(this.contactId));
if (person == null) {
throw new CommandException(MESSAGE_PERSON_NOT_FOUND + this.contactId);
}
Expand Down
Loading

0 comments on commit aebdfa4

Please sign in to comment.