forked from nus-cs2103-AY2223S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/ryanguai/tp
- Loading branch information
Showing
77 changed files
with
2,018 additions
and
661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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` | ||
|
||
|
@@ -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. | ||
|
||
|
@@ -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` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
src/main/java/seedu/address/logic/commands/EditPersonDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
104
src/main/java/seedu/address/logic/commands/EditTaskDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.