Skip to content

Commit

Permalink
Update UG for PPP (#246)
Browse files Browse the repository at this point in the history
* Update UG for note tag command

* Add more description for note untag

* Removes isSameContact

* Updates UserGuide

* Justify test
  • Loading branch information
Yehezkiel01 authored and tanlk99 committed Nov 11, 2019
1 parent 572b1ff commit 2a36e39
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 82 deletions.
36 changes: 34 additions & 2 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ Examples:
* `contact create --n John --p 81234567 --a 21 Kent Ridge Rd`
* `contact create --n Dwayne Johnson --p 81234567 --e d.johnson@gmail.com --d Friend from CS2100`

NOTE: Contacts with the same name is allowed only if they have different phone number and email address.

==== List all contacts: `list`

Lists all contacts in the application.
Expand Down Expand Up @@ -533,6 +531,38 @@ Format:

`note tag NOTE_ID [--t TAG]+`

In Tagline, there are 3 types of tags. They are hash tag, contact tag and group tag.

{empty} +

===== Tag a note with a hash tag

Hash tag is a tag of the form `#TOPIC` where `TOPIC` could be substituted with any string not longer than 30
characters.

Example: `#Assignment_1`, `#Project CS2103T`, `#Meeting Notes`

By tagging a note with a hash tag, user can easily find all notes related to a certain topic.

{empty} +

Here is an example of tagging a note with a hash tag

. Enter the command `note tag 1 --t #any topic` into the command box.
+
image::ug_notetag_hashtag1.png[width="600"]

. Send the command and you will be able to see the tag in the note view.
+
image::ug_notetag_hashtag2.png[width="600"]

{empty} +

===== Tag a note with a contact tag
===== Tag a note with a group tag
===== Tag a note with all tags
We can also combine the three tags above in one `note tag` command.

Example:

* `note tag 00002 --t #CS2103T --t #Duke --t @12300 --t %cs2103T`
Expand All @@ -547,6 +577,8 @@ Format:

`note untag NOTE_ID [--t TAG]+`

Similar with `note tag` command we can also untag a note with three types of tags.

Example:

* `note untag 00002 --t #CS2103T --t #Duke --t @12300 --t %cs2103T`
Expand Down
Binary file added docs/images/ug_notetag_hashtag1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ug_notetag_hashtag2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public CommandResult execute(Model model) throws CommandException {
Contact contactToEdit = contact.get();
Contact editedContact = createEditedContact(contactToEdit, editContactDescriptor);

if (!contactToEdit.isSameContact(editedContact) && model.hasContact(editedContact)) {
if (!contactToEdit.equals(editedContact) && model.hasContact(editedContact)) {
throw new CommandException(MESSAGE_DUPLICATE_CONTACT);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tagline/model/contact/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* Wraps all data at the address-book level
* Duplicates are not allowed (by .isSameContact comparison)
* Duplicates are not allowed (by .equals comparison)
*/
public class AddressBook implements ReadOnlyAddressBook {

Expand Down
14 changes: 0 additions & 14 deletions src/main/java/tagline/model/contact/Contact.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,6 @@ void setContactId(ContactId contactId) {
this.contactId = contactId;
}

/**
* Returns true if both contacts of the same name have at least one other identity field that is the same.
* This defines a weaker notion of equality between two contacts.
*/
public boolean isSameContact(Contact otherContact) {
if (otherContact == this) {
return true;
}

return otherContact != null
&& otherContact.getName().equals(getName())
&& (otherContact.getPhone().equals(getPhone()) || otherContact.getEmail().equals(getEmail()));
}

/**
* Returns true if both contacts have the same identity and data fields.
* This defines a stronger notion of equality between two contacts.
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/tagline/model/contact/UniqueContactList.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@

/**
* A list of contacts that enforces uniqueness between its elements and does not allow nulls.
* A contact is considered unique by comparing using {@code Contact#isSameContact(Contact)}.
* As such, adding and updating of
* contacts uses Contact#isSameContact(Contact) for equality so as to ensure that the contact being added or updated is
* unique in terms of identity in the UniqueContactList. However, the removal of a contact uses Contact#equals
* (Object) so
* as to ensure that the contact with exactly the same fields will be removed.
* A contact is considered unique by comparing using {@code Contact#equals(Object)}.
* <p>
* Supports a minimal set of list operations.
*
* @see Contact#isSameContact(Contact)
* @see Contact#equals(Object)
*/
public class UniqueContactList implements Iterable<Contact> {

Expand All @@ -36,7 +31,7 @@ public class UniqueContactList implements Iterable<Contact> {
*/
public boolean containsContact(Contact toCheck) {
requireNonNull(toCheck);
return internalList.stream().anyMatch(toCheck::isSameContact);
return internalList.stream().anyMatch(toCheck::equals);
}

/**
Expand Down Expand Up @@ -85,7 +80,7 @@ public void setContact(Contact target, Contact editedContact) {
throw new ContactNotFoundException();
}

if (!target.isSameContact(editedContact) && containsContact(editedContact)) {
if (!target.equals(editedContact) && containsContact(editedContact)) {
throw new DuplicateContactException();
}

Expand Down Expand Up @@ -151,7 +146,7 @@ public int hashCode() {
private boolean contactsAreUnique(List<Contact> contacts) {
for (int i = 0; i < contacts.size() - 1; i++) {
for (int j = i + 1; j < contacts.size(); j++) {
if (contacts.get(i).isSameContact(contacts.get(j))) {
if (contacts.get(i).equals(contacts.get(j))) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
}, {
"name": "Alice Pauline",
"phone": "94351253",
"email": "pauline@example.com",
"address": "4th street",
"email": "alice@example.com",
"address": "123, Jurong West Ave 6, #08-111",
"description": "friend",
"id": "2"
} ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private class ModelStubWithContact extends ModelStub {
@Override
public boolean hasContact(Contact contact) {
requireNonNull(contact);
return this.contact.isSameContact(contact);
return this.contact.equals(contact);
}
}

Expand All @@ -397,7 +397,7 @@ private class ModelStubAcceptingContactAdded extends ModelStub {
@Override
public boolean hasContact(Contact contact) {
requireNonNull(contact);
return contactsAdded.stream().anyMatch(contact::isSameContact);
return contactsAdded.stream().anyMatch(contact::equals);
}

@Override
Expand Down
12 changes: 1 addition & 11 deletions src/test/java/tagline/model/contact/AddressBookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static tagline.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
import static tagline.testutil.Assert.assertThrows;
import static tagline.testutil.contact.TypicalContacts.ALICE;
import static tagline.testutil.contact.TypicalContacts.getTypicalAddressBook;
Expand Down Expand Up @@ -43,8 +42,7 @@ public void resetData_withValidReadOnlyAddressBook_replacesData() {
@Test
public void resetData_withDuplicateContacts_throwsDuplicateContactException() {
// Two contacts with the same identity fields
Contact editedAlice = new ContactBuilder(ALICE).withAddress(VALID_ADDRESS_BOB)
.build();
Contact editedAlice = new ContactBuilder(ALICE).build();
List<Contact> newContacts = Arrays.asList(ALICE, editedAlice);
AddressBookStub newData = new AddressBookStub(newContacts);

Expand All @@ -67,14 +65,6 @@ public void hasContact_contactInAddressBook_returnsTrue() {
assertTrue(addressBook.hasContact(ALICE));
}

@Test
public void hasContact_contactWithSameIdentityFieldsInAddressBook_returnsTrue() {
addressBook.addContact(ALICE);
Contact editedAlice = new ContactBuilder(ALICE).withAddress(VALID_ADDRESS_BOB)
.build();
assertTrue(addressBook.hasContact(editedAlice));
}

@Test
public void getContactList_modifyList_throwsUnsupportedOperationException() {
assertThrows(UnsupportedOperationException.class, () -> addressBook.getContactList().remove(0));
Expand Down
31 changes: 0 additions & 31 deletions src/test/java/tagline/model/contact/ContactTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,6 @@

public class ContactTest {

@Test
public void isSameContact() {
// same object -> returns true
assertTrue(ALICE.isSameContact(ALICE));

// null -> returns false
assertFalse(ALICE.isSameContact(null));

// different phone and email -> returns false
Contact editedAlice = new ContactBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).build();
assertFalse(ALICE.isSameContact(editedAlice));

// different name -> returns false
editedAlice = new ContactBuilder(ALICE).withName(VALID_NAME_BOB).build();
assertFalse(ALICE.isSameContact(editedAlice));

// same name, same phone, different attributes -> returns true
editedAlice = new ContactBuilder(ALICE).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB)
.build();
assertTrue(ALICE.isSameContact(editedAlice));

// same name, same email, different attributes -> returns true
editedAlice = new ContactBuilder(ALICE).withPhone(VALID_PHONE_BOB).withAddress(VALID_ADDRESS_BOB)
.build();
assertTrue(ALICE.isSameContact(editedAlice));

// same name, same phone, same email, different attributes -> returns true
editedAlice = new ContactBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build();
assertTrue(ALICE.isSameContact(editedAlice));
}

@Test
public void equals() {
// same values -> returns true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ public void containsContact_contactInList_returnsTrue() {
assertTrue(uniqueContactList.containsContact(ALICE));
}

@Test
public void containsContact_contactWithSameIdentityFieldsInList_returnsTrue() {
uniqueContactList.addContact(ALICE);
Contact editedAlice = new ContactBuilder(ALICE).withAddress(VALID_ADDRESS_BOB)
.build();
assertTrue(uniqueContactList.containsContact(editedAlice));
}

@Test
public void addContact_nullContact_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> uniqueContactList.addContact(null));
Expand Down

0 comments on commit 2a36e39

Please sign in to comment.