Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ryanguai/tp
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanguai committed Oct 13, 2022
2 parents 3b749f9 + cbde9d5 commit 3c323fa
Show file tree
Hide file tree
Showing 77 changed files with 2,018 additions and 661 deletions.
42 changes: 21 additions & 21 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ YellowBook is optimised for use via a Command Line Interface (CLI).

Adds a contact to the address book.

Format: `addC n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [d/DESCRIPTION]`
Format: `addC n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [r/REMARK]`

* The description of a contact is optional.
* The remark of a contact is optional.

Examples:

* `addC n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01`

* `addC n/Betsy Crowe e/[email protected] a/Newgate Prison p/1234567 d/Weird person.`
* `addC n/Betsy Crowe e/[email protected] a/Newgate Prison p/1234567 r/Weird person.`

### Listing all contacts: `listC`

Expand Down Expand Up @@ -103,7 +103,7 @@ Examples:

Edits the information fields (e.g. name, mobile number, email address) of an existing contact in the address book.

Format: `editC INDEX [n/NAME] [p/PHONE] [a/ADDRESS] [d/Description]`
Format: `editC INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [r/REMARK]`

* Index of a contact is its index number on the contact list.

Expand Down Expand Up @@ -347,20 +347,20 @@ If your changes to the data file makes its format invalid, YellowBook will disca

## Command summary

| Action | Format, Examples |
|------------|------------------------------------------------------------------------------------------------------|
| **listC** | `listC` |
| **addC** | `addC n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [d/DESCRIPTION]` <br> e.g., `addC n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01` |
| **deleteC** | `deleteC INDEX` <br> e.g., `deleteC 1` |
| **editC** | `editC INDEX [n/NAME] [p/PHONE] [a/ADDRESS] [d/Description]` <br> e.g., `editC 1 n/John p/12345678` |
| **findC** | `findC KEYWORD [MORE_KEYWORDS]` <br> e.g., `findC Phineas Ferb` |
| **filterC** | `filterC KEYWORD [MORE_KEYWORDS]` <br> e.g., `filterT cs2103t` | |
| **listT** | `listT` |
| **addT** | `addT d/DESCRIPTION D/DEADLINE` |
| **markT** | `markT INDEX` <br> e.g., `mark 1` |
| **unmarkT** | `unmarkT INDEX` <br> e.g., `unmark 1` |
| **searchT** | `findT KEYWORD [MORE_KEYWORDS]` <br> e.g., `findT cs2103t` |
| **filterT** | `filterT KEYWORD [MORE_KEYWORDS]` <br> e.g., `filterT cs2103t` |
| **listL** | `listL` |
| **addL** | `addL c/INDEX n/LABEL_NAME` OR `addL t/INDEX n/LABEL_NAME` |
| **deleteL** | `deleteL c/INDEX n/LABEL_NAME` OR `deleteL t/INDEX n/LABEL_NAME` |
| Action | Format, Examples |
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| **listC** | `listC` |
| **addC** | `addC n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [r/REMARK]` <br> e.g., `addC n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01` |
| **deleteC** | `deleteC INDEX` <br> e.g., `deleteC 1` |
| **editC** | `editC INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [r/REMARK]` <br> e.g., `editC 1 n/John p/12345678` |
| **findC** | `findC KEYWORD [MORE_KEYWORDS]` <br> e.g., `findC Phineas Ferb` |
| **filterC** | `filterC KEYWORD [MORE_KEYWORDS]` <br> e.g., `filterT cs2103t` | |
| **listT** | `listT` |
| **addT** | `addT d/DESCRIPTION D/DEADLINE` |
| **markT** | `markT INDEX` <br> e.g., `mark 1` |
| **unmarkT** | `unmarkT INDEX` <br> e.g., `unmark 1` |
| **searchT** | `findT KEYWORD [MORE_KEYWORDS]` <br> e.g., `findT cs2103t` |
| **filterT** | `filterT KEYWORD [MORE_KEYWORDS]` <br> e.g., `filterT cs2103t` |
| **listL** | `listL` |
| **addL** | `addL c/INDEX n/LABEL_NAME` OR `addL t/INDEX n/LABEL_NAME` |
| **deleteL** | `deleteL c/INDEX n/LABEL_NAME` OR `deleteL t/INDEX n/LABEL_NAME` |
1 change: 1 addition & 0 deletions src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public class Messages {
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
public static final String MESSAGE_INVALID_TASK_DISPLAYED_INDEX = "The task index provided is invalid";

public static final String MESSAGE_TASKS_LISTED_OVERVIEW = "%1$d tasks listed!";
}
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Person;
import seedu.address.model.tag.Tag;
import seedu.address.model.task.Task;

/**
Expand Down Expand Up @@ -37,6 +38,9 @@ public interface Logic {
/** Returns an unmodifiable view of the filtered list of tasks */
ObservableList<Task> getFilteredTaskList();

/** Returns an unmodifiable view of the filtered list of tags */
ObservableList<Tag> getTagList();

/**
* Returns the user prefs' address book file path.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Person;
import seedu.address.model.tag.Tag;
import seedu.address.model.task.Task;
import seedu.address.storage.Storage;

Expand Down Expand Up @@ -70,6 +71,11 @@ public ObservableList<Task> getFilteredTaskList() {
return model.getFilteredTaskList();
}

@Override
public ObservableList<Tag> getTagList() {
return model.getTagList();
}

@Override
public Path getAddressBookFilePath() {
return model.getAddressBookFilePath();
Expand Down
129 changes: 129 additions & 0 deletions src/main/java/seedu/address/logic/commands/EditPersonDescriptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package seedu.address.logic.commands;

import java.util.Collections;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

import seedu.address.commons.util.CollectionUtil;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Remark;
import seedu.address.model.tag.Tag;

/**
* Stores the details to edit the person with. Each non-empty field value will replace the
* corresponding field value of the person.
*/
public class EditPersonDescriptor {
private Name name;
private Phone phone;
private Email email;
private Address address;
private Remark remark;
private Set<Tag> tags;

public EditPersonDescriptor() {}

/**
* Copy constructor.
* A defensive copy of {@code tags} is used internally.
*/
public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setName(toCopy.name);
setPhone(toCopy.phone);
setEmail(toCopy.email);
setAddress(toCopy.address);
setRemark(toCopy.remark);
setTags(toCopy.tags);
}

/**
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone, email, address, remark, tags);
}

public void setName(Name name) {
this.name = name;
}

public Optional<Name> getName() {
return Optional.ofNullable(name);
}

public void setPhone(Phone phone) {
this.phone = phone;
}

public Optional<Phone> getPhone() {
return Optional.ofNullable(phone);
}

public void setEmail(Email email) {
this.email = email;
}

public Optional<Email> getEmail() {
return Optional.ofNullable(email);
}

public void setAddress(Address address) {
this.address = address;
}

public Optional<Address> getAddress() {
return Optional.ofNullable(address);
}

public void setRemark(Remark remark) {
this.remark = remark;
}

public Optional<Remark> getRemark() {
return Optional.ofNullable(remark);
}

/**
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
*/
public void setTags(Set<Tag> tags) {
this.tags = (tags != null) ? new HashSet<>(tags) : null;
}

/**
* Returns an unmodifiable tag set, which throws {@code UnsupportedOperationException}
* if modification is attempted.
* Returns {@code Optional#empty()} if {@code tags} is null.
*/
public Optional<Set<Tag>> getTags() {
return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty();
}

@Override
public boolean equals(Object other) {
// short circuit if same object
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof EditPersonDescriptor)) {
return false;
}

// state check
EditPersonDescriptor e = (EditPersonDescriptor) other;

return getName().equals(e.getName())
&& getPhone().equals(e.getPhone())
&& getEmail().equals(e.getEmail())
&& getAddress().equals(e.getAddress())
&& getRemark().equals(e.getRemark())
&& getTags().equals(e.getTags());
}
}
104 changes: 104 additions & 0 deletions src/main/java/seedu/address/logic/commands/EditTaskDescriptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package seedu.address.logic.commands;

import java.util.Collections;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

import seedu.address.commons.util.CollectionUtil;
import seedu.address.model.tag.Tag;
import seedu.address.model.task.Deadline;
import seedu.address.model.task.Description;

/**
* Stores the details to edit the task with. Each non-empty field value will replace the
* corresponding field value of the task.
*/
public class EditTaskDescriptor {
private Description description;
private Deadline deadline;
private boolean isDone;
private Set<Tag> tags;

public EditTaskDescriptor() {}

/**
* Copy constructor.
* A defensive copy of {@code tags} is used internally.
*/
public EditTaskDescriptor(EditTaskDescriptor toCopy) {
setDescription(toCopy.description);
setDeadline(toCopy.deadline);
setIsDone(toCopy.isDone);
setTags(toCopy.tags);
}

/**
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(description, isDone, tags);
}

public void setDescription(Description description) {
this.description = description;
}

public Optional<Description> getDescription() {
return Optional.ofNullable(description);
}

public void setDeadline(Deadline deadline) {
this.deadline = deadline;
}

public Optional<Deadline> getDeadline() {
return Optional.ofNullable(deadline);
}

public void setIsDone(boolean isDone) {
this.isDone = isDone;
}

public Optional<Boolean> getIsDone() {
return Optional.ofNullable(isDone);
}

/**
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
*/
public void setTags(Set<Tag> tags) {
this.tags = (tags != null) ? new HashSet<>(tags) : null;
}

/**
* Returns an unmodifiable tag set, which throws {@code UnsupportedOperationException}
* if modification is attempted.
* Returns {@code Optional#empty()} if {@code tags} is null.
*/
public Optional<Set<Tag>> getTags() {
return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty();
}

@Override
public boolean equals(Object other) {
// short circuit if same object
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof EditTaskDescriptor)) {
return false;
}

// state check
EditTaskDescriptor e = (EditTaskDescriptor) other;

return getDescription().equals(e.getDescription())
&& getDeadline().equals(e.getDeadline())
&& getIsDone().equals(e.getIsDone())
&& getTags().equals(e.getTags());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK;

import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
Expand All @@ -26,14 +26,13 @@ public class AddContactCommand extends Command {
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "[" + PREFIX_REMARK + "REMARK] "
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "johnd@example.com "
+ PREFIX_EMAIL + "johndoe@example.com "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "owesMoney";
+ PREFIX_REMARK + "friends";

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
Expand Down
Loading

0 comments on commit 3c323fa

Please sign in to comment.