Skip to content

Commit

Permalink
Merge pull request #182 from solomonng2001/fix-bugs-and-update-ug
Browse files Browse the repository at this point in the history
Update sorting, user guide and json path
  • Loading branch information
ReganChoy authored Apr 11, 2024
2 parents cbaf733 + fb0fdab commit 2768965
Show file tree
Hide file tree
Showing 18 changed files with 15 additions and 123 deletions.
10 changes: 5 additions & 5 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ download ClientCare.

2. Download the latest version of ClientCare by downloading the `clientcare.jar` file found [here](https://github.com/AY2324S2-CS2103T-W12-1/tp/releases).

![Tag](images/ug/ReleaseTag%20v1.2.jpg =600x)
![Tag](images/ug/ReleaseTag%20v1.2.png =600x)

<box type="info">

**Note:** The ClientCare application file can be found at the bottom of the release notes, under Assets!
</box>

![jar](images/ug/clientcare%20jar%20file%20v1.2.jpg =600x)
![jar](images/ug/clientcare%20jar%20file%20v1.2.png =600x)

3. Create a new empty folder (with any name you like) in your computer where you'd like to store ClientCare.

Expand Down Expand Up @@ -207,7 +207,7 @@ Let's learn the language that ClientCare speaks in.
### ClientCare Commands
A ClientCare command has the following parts:

![Command Structure](images/ug/commandStructure.jpg =450x)
![Command Structure](images/ug/commandStructure.png =450x)

##### 1) Command Keyword
This keyword tells ClientCare what you want to do. If you want to add a new client, then `add` will be the keyword.
Expand Down Expand Up @@ -656,13 +656,13 @@ Want to see all your VIP clients first? You can sort the client list with `sort`
Format: `sort CRITERIA o/ORDER`

* Sorts the client list by the specified `CRITERIA`. Sorting `CRITERIA` is *case-insensitive*.
* Sortng `CRITERIA` can be `name`, `phone`, `email`, `address`, `birthday`, `priority`, `lastmet`, `schedule`.
* Sortng `CRITERIA` can be `name`, `birthday`, `priority`.
* Sorting `ORDER` is specified by `ORDER` and can be `asc` for ascending or `desc` for descending. Sorting `ORDER` is *case-insensitive*

Examples:
* `sort name o/asc` sorts the client list by name in ascending order.
* `sort priority o/desc` sorts the client list by priority in descending order.
* `sort lastmet o/asc` sorts the client list by last met date in ascending order.
* `sort birthday o/asc` sorts the client list by birthday date in ascending order.

**Before Command:**

Expand Down
File renamed without changes
Binary file modified docs/images/ug/clientViewAndList.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file removed docs/images/ug/commandStructure.jpg
Binary file not shown.
Binary file modified docs/images/ug/commandStructure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/ug/policies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/ug/reminders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/tutorials/AddRemark.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ While the changes to code may be minimal, the test data will have to be updated

<box type="warning" seamless>

You must delete AddressBook’s storage file located at `/data/addressbook.json` before running it! Not doing so will cause AddressBook to default to an empty address book!
You must delete AddressBook’s storage file located at `/data/clientcare.json` before running it! Not doing so will cause AddressBook to default to an empty address book!

</box>

Expand Down
15 changes: 0 additions & 15 deletions src/main/java/seedu/address/model/person/PersonComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,12 @@ public static Comparator<Person> getComparator(SortCriteria sortCriteria, SortOr
case NAME:
comparator = Comparator.comparing(Person::getName);
break;
case PHONE:
comparator = Comparator.comparing(Person::getPhone);
break;
case EMAIL:
comparator = Comparator.comparing(Person::getEmail);
break;
case ADDRESS:
comparator = Comparator.comparing(Person::getAddress);
break;
case PRIORITY:
comparator = Comparator.comparing(Person::getPriority);
break;
case BIRTHDAY:
comparator = Comparator.comparing(Person::getBirthday);
break;
case LASTMET:
comparator = Comparator.comparing(Person::getLastMet);
break;
case SCHEDULE:
comparator = Comparator.comparing(Person::getSchedule);
break;
default:
return COMPARATOR_SHOW_ORIGINAL_ORDER;
}
Expand Down
12 changes: 1 addition & 11 deletions src/main/java/seedu/address/model/person/SortCriteria.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,14 @@
*/
public enum SortCriteria {
NAME,
PHONE,
EMAIL,
ADDRESS,
BIRTHDAY,
PRIORITY,
LASTMET,
SCHEDULE,
INVALID;

public static final String MESSAGE_CONSTRAINTS = "Sort criteria should be either "
+ SortCriteria.NAME + ", "
+ SortCriteria.PHONE + ", "
+ SortCriteria.EMAIL + ", "
+ SortCriteria.ADDRESS + ", "
+ SortCriteria.BIRTHDAY + ", "
+ SortCriteria.PRIORITY + ", "
+ SortCriteria.LASTMET + " or "
+ SortCriteria.SCHEDULE + ".";
+ SortCriteria.BIRTHDAY + ".";

/**
* Returns the sort criteria given the string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"z" : 99
}
},
"addressBookFilePath" : "addressbook.json"
"addressBookFilePath" : "clientcare.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"y" : 100
}
},
"addressBookFilePath" : "addressbook.json"
"addressBookFilePath" : "clientcare.json"
}
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class LogicManagerTest {
@BeforeEach
public void setUp() {
JsonAddressBookStorage addressBookStorage =
new JsonAddressBookStorage(temporaryFolder.resolve("addressBook.json"));
new JsonAddressBookStorage(temporaryFolder.resolve("clientcare.json"));
JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json"));
StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage);
logic = new LogicManager(model, storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
public class SortCommandParserTest {
public static final String VALID_SORT_NAME_ASC = SortCriteria.NAME + " " + PREFIX_SORT_ORDER + SortOrder.ASC;
public static final String VALID_SORT_NAME_DESC = SortCriteria.NAME + " " + PREFIX_SORT_ORDER + SortOrder.DESC;
public static final String VALID_SORT_PHONE_ASC = SortCriteria.PHONE + " " + PREFIX_SORT_ORDER + SortOrder.ASC;
public static final String VALID_SORT_PHONE_DESC = SortCriteria.PHONE + " " + PREFIX_SORT_ORDER + SortOrder.DESC;
public static final String VALID_SORT_EMAIL_ASC = SortCriteria.EMAIL + " " + PREFIX_SORT_ORDER + SortOrder.ASC;
public static final String VALID_SORT_EMAIL_DESC = SortCriteria.EMAIL + " " + PREFIX_SORT_ORDER + SortOrder.DESC;
public static final String VALID_SORT_ADDRESS_ASC = SortCriteria.ADDRESS + " " + PREFIX_SORT_ORDER + SortOrder.ASC;
public static final String VALID_SORT_ADDRESS_DESC = SortCriteria.ADDRESS + " " + PREFIX_SORT_ORDER
+ SortOrder.DESC;
public static final String VALID_SORT_PRIORITY_ASC = SortCriteria.PRIORITY + " " + PREFIX_SORT_ORDER
+ SortOrder.ASC;
public static final String VALID_SORT_PRIORITY_DESC = SortCriteria.PRIORITY + " " + PREFIX_SORT_ORDER
Expand All @@ -30,13 +23,6 @@ public class SortCommandParserTest {
+ SortOrder.ASC;
public static final String VALID_SORT_BIRTHDAY_DESC = SortCriteria.BIRTHDAY + " " + PREFIX_SORT_ORDER
+ SortOrder.DESC;
public static final String VALID_SORT_LASTMET_ASC = SortCriteria.LASTMET + " " + PREFIX_SORT_ORDER + SortOrder.ASC;
public static final String VALID_SORT_LASTMET_DESC = SortCriteria.LASTMET + " " + PREFIX_SORT_ORDER
+ SortOrder.DESC;
public static final String VALID_SORT_SCHEDULE_ASC = SortCriteria.SCHEDULE + " " + PREFIX_SORT_ORDER
+ SortOrder.ASC;
public static final String VALID_SORT_SCHEDULE_DESC = SortCriteria.SCHEDULE + " " + PREFIX_SORT_ORDER
+ SortOrder.DESC;

private final SortCommandParser parser = new SortCommandParser();

Expand All @@ -47,18 +33,6 @@ public void parse_allFieldsPresent_success() {
new SortCommand(SortCriteria.NAME, SortOrder.ASC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_NAME_DESC,
new SortCommand(SortCriteria.NAME, SortOrder.DESC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_PHONE_ASC,
new SortCommand(SortCriteria.PHONE, SortOrder.ASC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_PHONE_DESC,
new SortCommand(SortCriteria.PHONE, SortOrder.DESC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_EMAIL_ASC,
new SortCommand(SortCriteria.EMAIL, SortOrder.ASC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_EMAIL_DESC,
new SortCommand(SortCriteria.EMAIL, SortOrder.DESC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_ADDRESS_ASC,
new SortCommand(SortCriteria.ADDRESS, SortOrder.ASC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_ADDRESS_DESC,
new SortCommand(SortCriteria.ADDRESS, SortOrder.DESC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_PRIORITY_ASC,
new SortCommand(SortCriteria.PRIORITY, SortOrder.ASC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_PRIORITY_DESC,
Expand All @@ -67,32 +41,14 @@ public void parse_allFieldsPresent_success() {
new SortCommand(SortCriteria.BIRTHDAY, SortOrder.ASC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_BIRTHDAY_DESC,
new SortCommand(SortCriteria.BIRTHDAY, SortOrder.DESC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_LASTMET_ASC,
new SortCommand(SortCriteria.LASTMET, SortOrder.ASC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_LASTMET_DESC,
new SortCommand(SortCriteria.LASTMET, SortOrder.DESC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_SCHEDULE_ASC,
new SortCommand(SortCriteria.SCHEDULE, SortOrder.ASC));
assertParseSuccess(parser, PREAMBLE_WHITESPACE + VALID_SORT_SCHEDULE_DESC,
new SortCommand(SortCriteria.SCHEDULE, SortOrder.DESC));

// without whitespace preamble
assertParseSuccess(parser, VALID_SORT_NAME_ASC, new SortCommand(SortCriteria.NAME, SortOrder.ASC));
assertParseSuccess(parser, VALID_SORT_NAME_DESC, new SortCommand(SortCriteria.NAME, SortOrder.DESC));
assertParseSuccess(parser, VALID_SORT_PHONE_ASC, new SortCommand(SortCriteria.PHONE, SortOrder.ASC));
assertParseSuccess(parser, VALID_SORT_PHONE_DESC, new SortCommand(SortCriteria.PHONE, SortOrder.DESC));
assertParseSuccess(parser, VALID_SORT_EMAIL_ASC, new SortCommand(SortCriteria.EMAIL, SortOrder.ASC));
assertParseSuccess(parser, VALID_SORT_EMAIL_DESC, new SortCommand(SortCriteria.EMAIL, SortOrder.DESC));
assertParseSuccess(parser, VALID_SORT_ADDRESS_ASC, new SortCommand(SortCriteria.ADDRESS, SortOrder.ASC));
assertParseSuccess(parser, VALID_SORT_ADDRESS_DESC, new SortCommand(SortCriteria.ADDRESS, SortOrder.DESC));
assertParseSuccess(parser, VALID_SORT_PRIORITY_ASC, new SortCommand(SortCriteria.PRIORITY, SortOrder.ASC));
assertParseSuccess(parser, VALID_SORT_PRIORITY_DESC, new SortCommand(SortCriteria.PRIORITY, SortOrder.DESC));
assertParseSuccess(parser, VALID_SORT_BIRTHDAY_ASC, new SortCommand(SortCriteria.BIRTHDAY, SortOrder.ASC));
assertParseSuccess(parser, VALID_SORT_BIRTHDAY_DESC, new SortCommand(SortCriteria.BIRTHDAY, SortOrder.DESC));
assertParseSuccess(parser, VALID_SORT_LASTMET_ASC, new SortCommand(SortCriteria.LASTMET, SortOrder.ASC));
assertParseSuccess(parser, VALID_SORT_LASTMET_DESC, new SortCommand(SortCriteria.LASTMET, SortOrder.DESC));
assertParseSuccess(parser, VALID_SORT_SCHEDULE_ASC, new SortCommand(SortCriteria.SCHEDULE, SortOrder.ASC));
assertParseSuccess(parser, VALID_SORT_SCHEDULE_DESC, new SortCommand(SortCriteria.SCHEDULE, SortOrder.DESC));
}

@Test
Expand Down
39 changes: 0 additions & 39 deletions src/test/java/seedu/address/model/person/PersonComparatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,6 @@ public void getComparator() {
assertTrue(nameDescComparator.compare(alice, bob) > 0);
assertEquals(0, nameDescComparator.compare(alice, aliceCopy));

// sort by phone
Person phone1 = new PersonBuilder().withPhone("12345678").build();
Person phone1Copy = new PersonBuilder().withPhone("12345678").build();
Person phone2 = new PersonBuilder().withPhone("87654321").build();
// ascending
Comparator<Person> phoneAscComparator = PersonComparator.getComparator(SortCriteria.PHONE, SortOrder.ASC);
assertTrue(phoneAscComparator.compare(phone1, phone2) < 0);
assertEquals(0, phoneAscComparator.compare(phone1, phone1Copy));
// descending
Comparator<Person> phoneDescComparator = PersonComparator.getComparator(SortCriteria.PHONE, SortOrder.DESC);
assertTrue(phoneDescComparator.compare(phone1, phone2) > 0);
assertEquals(0, phoneDescComparator.compare(phone1, phone1Copy));

// sort by email
Person email1 = new PersonBuilder().withEmail("abc@email.com").build();
Person email1Copy = new PersonBuilder().withEmail("abc@email.com").build();
Person email2 = new PersonBuilder().withEmail("bcd@email.com").build();
// ascending
Comparator<Person> emailAscComparator = PersonComparator.getComparator(SortCriteria.EMAIL, SortOrder.ASC);
assertTrue(emailAscComparator.compare(email1, email2) < 0);
assertEquals(0, emailAscComparator.compare(email1, email1Copy));
// descending
Comparator<Person> emailDescComparator = PersonComparator.getComparator(SortCriteria.EMAIL, SortOrder.DESC);
assertTrue(emailDescComparator.compare(email1, email2) > 0);
assertEquals(0, emailDescComparator.compare(email1, email1Copy));

// sort by address
Person address1 = new PersonBuilder().withAddress("123, Clementi Ave 3").build();
Person address1Copy = new PersonBuilder().withAddress("123, Clementi Ave 3").build();
Person address2 = new PersonBuilder().withAddress("456, Clementi Ave 4").build();
// ascending
Comparator<Person> addressAscComparator = PersonComparator.getComparator(SortCriteria.ADDRESS, SortOrder.ASC);
assertTrue(addressAscComparator.compare(address1, address2) < 0);
assertEquals(0, addressAscComparator.compare(address1, address1Copy));
// descending
Comparator<Person> addressDescComparator = PersonComparator.getComparator(SortCriteria.ADDRESS, SortOrder.DESC);
assertTrue(addressDescComparator.compare(address1, address2) > 0);
assertEquals(0, addressDescComparator.compare(address1, address1Copy));

// sort by priority
Person priority1 = new PersonBuilder().withPriority("low").build();
Person priority1Copy = new PersonBuilder().withPriority("low").build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public void constructor_invalidPriority_returnsInvalid() {
public void constructor_validPriority_success() {
assertEquals(SortCriteria.getSortCriteria("name"), SortCriteria.NAME); // lowercase
assertEquals(SortCriteria.getSortCriteria("priority"), SortCriteria.PRIORITY); // lowercase
assertEquals(SortCriteria.getSortCriteria("lastmet"), SortCriteria.LASTMET); // lowercase
assertEquals(SortCriteria.getSortCriteria("birthday"), SortCriteria.BIRTHDAY); // lowercase
assertEquals(SortCriteria.getSortCriteria("NAME"), SortCriteria.NAME); // uppercase
assertEquals(SortCriteria.getSortCriteria("PRIORITY"), SortCriteria.PRIORITY); // uppercase
assertEquals(SortCriteria.getSortCriteria("LASTMET"), SortCriteria.LASTMET); // uppercase
assertEquals(SortCriteria.getSortCriteria("BIRTHDAY"), SortCriteria.BIRTHDAY); // uppercase
}

@Test
Expand All @@ -54,10 +54,10 @@ public void isValidSortCriteria() {
// valid sort criteria
assertTrue(SortCriteria.isValidSortCriteria("name")); // lowercase
assertTrue(SortCriteria.isValidSortCriteria("priority")); // lowercase
assertTrue(SortCriteria.isValidSortCriteria("lastmet")); // lowercase
assertTrue(SortCriteria.isValidSortCriteria("birthday")); // lowercase
assertTrue(SortCriteria.isValidSortCriteria("NAME")); // uppercase
assertTrue(SortCriteria.isValidSortCriteria("PRIORITY")); // uppercase
assertTrue(SortCriteria.isValidSortCriteria("LASTMET")); // uppercase
assertTrue(SortCriteria.isValidSortCriteria("BIRTHDAY")); // uppercase
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void readUserPrefs_extraValuesInFile_extraValuesIgnored() throws DataLoad
private UserPrefs getTypicalUserPrefs() {
UserPrefs userPrefs = new UserPrefs();
userPrefs.setGuiSettings(new GuiSettings(1000, 500, 300, 100));
userPrefs.setAddressBookFilePath(Paths.get("addressbook.json"));
userPrefs.setAddressBookFilePath(Paths.get("clientcare.json"));
return userPrefs;
}

Expand Down

0 comments on commit 2768965

Please sign in to comment.