diff --git a/docs/UserGuide.md b/docs/UserGuide.md index d8dc19f8b4d..ebd5492a2d3 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -251,15 +251,15 @@ _This command adds a new client to your client list._ -| Parameter | Description | Remarks | -|----------------|----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| n/NAME | Name of client that you want to add | Name must be unique, alphanumeric and case-sensitive. It is also compulsory | -| p/PHONE_NUMBER | Phone Number of client that you want to add | Phone number should only contain numbers and is compulsory | -| e/EMAIL | Email of client that you want to add | Emails should be of the format local-part@domain and adhere to the following constraints:
1. The local-part should only contain alphanumeric characters and these special characters, excluding the parentheses, (+_.-). The local-part may not start or end with any special characters.
2. This is followed by a '@' and then a domain name. The domain name is made up of domain labels separated by periods.
The domain name must:
- end with a domain label at least 2 characters long
- have each domain label start and end with alphanumeric characters
- have each domain label consist of alphanumeric characters, separated only by hyphens, if any. | -| a/ADDRESS | Address of client that you want to add | - | -| k/NEXT_OF_KIN | Next of Kin details of client that you want to add | Name must be alphanumeric | -| d/DESCRIPTION | Description of client that you want to add | Description should not be blank | -| t/TAG | Tag to identify the client | A person can have any number of tags (or even 0). Tags should be alphanumeric and should not contain spaces or other special characters. | +| Parameter | Description | Remarks | +|----------------|----------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| n/NAME | Name of client that you want to add | Name must be unique, alphanumeric and case-sensitive. It is also compulsory | +| p/PHONE_NUMBER | Phone Number of client that you want to add | Phone number should only contain numbers and is compulsory | +| e/EMAIL | Email of client that you want to add | Emails should be of the format local-part@domain and adhere to the following constraints:
1. The local-part should only contain alphanumeric characters and these special characters, excluding the parentheses, (+_.-). The local-part may not start or end with any special characters.
2. This is followed by a '@' and then a domain name. The domain name is made up of one or more domain labels separated by periods.
The domain name must:
- end with a domain label at least 2 characters long
- have each domain label start and end with alphanumeric characters
- have each domain label consist of alphanumeric characters, separated only by hyphens, if any.
- Valid emails include: PeterJack_1190@example.com, felix@asd, e1234567@u.nus.edu | +| a/ADDRESS | Address of client that you want to add | - | +| k/NEXT_OF_KIN | Next of Kin details of client that you want to add | Name must be alphanumeric | +| d/DESCRIPTION | Description of client that you want to add | Description should not be blank | +| t/TAG | Tag to identify the client | A person can have any number of tags (or even 0). Tags should be alphanumeric and should not contain spaces or other special characters. | @@ -631,12 +631,12 @@ _This command allows you to add an appointment with the specified parameters._ -| Parameter | Description | Remarks | -|-------------|-------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| HEADING | The heading of the appointment | The heading must contain only alpha-numeric characters and should not be more than 70 characters | -| TIME | The time of the appointment | The time of the appointment must conform to one of these formats: "M/d/yyyy HHmm", "M/d/yyyy", "yyyy-MM-dd", "yyyy-MM-dd HHmm", "MMM d yyyy", "EEEE, MMMM, dd, yyyy - hh:mm a". Refer to [this Java Documentation article](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html) for more information about what these formats mean. | -| DESCRIPTION | The description of the appointment | Description should not be blank | -| CLIENT_NAME | The name of the client in the appointment | The name should contain only alpha-numeric characters and spaces and shouldn't be blank | +| Parameter | Description | Remarks | +|-------------|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| HEADING | The heading of the appointment | The heading must contain only alpha-numeric characters and should not be more than 70 characters | +| TIME | The time of the appointment | The time of the appointment must conform to this format: "EEEE, MMMM, dd, yyyy - hh:mm a".
Note that day of the week (EEEE), month (MMMM), day of the month (dd), year (yyyy)
Refer to [this Java Documentation article](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html) for more information about what this format means. | +| DESCRIPTION | The description of the appointment | Description should not be blank | +| CLIENT_NAME | The name of the client in the appointment | The name should contain only alpha-numeric characters and spaces and shouldn't be blank |
@@ -884,16 +884,18 @@ ___ # Command summary -| Action | Format | Examples | -|-------------|-----------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| -| **Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL [a/ADDRESS] [k/NEXTOFKIN] [d/DESCRIPTION] [t/TAG]… ` | `add n/James Ho p/22224444 e/jamesho@example.com a/123, Clementi Rd, 1234665 d/Suffers from anxiety k/Jon Ho t/friend t/colleague` | -| **Update** | `update u/existing user [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…` | `Update u/Jane Doe n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-011` | -| **Find** | `find n/NAME… [a/ADD]… [e/EMAIL]… [t/TAG]… [k/KIN]… [d/DESC]… [p/PHONE]…` | `find n/James a/clementi e/gmail t/important k/charles d/tall p/123` | -| **Undo** | `undo` | | -| **Redo** | `redo` | | -| **Display** | `display NAME` | | -| **Clear** | `clear` | | -| **Exit** | `exit` | | +| Action | Format | Examples | +|---------------------|--------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| +| **Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL [a/ADDRESS] [k/NEXTOFKIN] [d/DESCRIPTION] [t/TAG]… ` | `add n/James Ho p/22224444 e/jamesho@example.com a/123, Clementi Rd, 1234665 d/Suffers from anxiety k/Jon Ho t/friend t/colleague` | +| **Update** | `update u/existing user [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…` | `Update u/Jane Doe n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-011` | +| **Find** | `find [n/NAME]… [a/ADD]… [e/EMAIL]… [t/TAG]… [k/KIN]… [d/DESC]… [p/PHONE]…` | `find n/James a/clementi e/gmail t/important k/charles d/tall p/123` | +| **Add Schedule** | `schedule add h/HEADING t/TIME d/DESCRIPTION n/CLIENT_NAME` | `schedule add h/Meeting with Client t/Wednesday, January, 24, 2024 - 09:00 AM d/Discuss project details n/John Doe` | +| **Delete Schedule** | `schedule delete h/HEADING` | `schedule delete h/Meeting with Client` | +| **Undo** | `undo` | | +| **Redo** | `redo` | | +| **Display** | `display NAME` | | +| **Clear** | `clear` | | +| **Exit** | `exit` | | Click [here](#table-of-contents) to return to the table of contents! ___ diff --git a/src/main/java/seedu/address/model/event/Time.java b/src/main/java/seedu/address/model/event/Time.java index 3678ddafcdb..7f071e716c4 100644 --- a/src/main/java/seedu/address/model/event/Time.java +++ b/src/main/java/seedu/address/model/event/Time.java @@ -5,18 +5,16 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; -import java.time.temporal.ChronoField; /** * An object that represents the time for a particular event */ public class Time { - public static final String MESSAGE_CONSTRAINTS = "Time should be of format: EEEE, MMMM, dd, yyyy - hh:mm a. " + public static final String MESSAGE_CONSTRAINTS = "Time should be of format: EEEE, MMMM, dd, yyyy - hh:mm a. \n" + "Note that day of the week (EEEE), month (MMMM), day of the month (dd), year (yyyy), " - + "time in 12-hour format (hh:mm), and am/pm indicator (a)."; - + + "time in 12-hour format (hh:mm), and AM/PM indicator (a).\n" + + "Note that AM/PM indicator must be capitalised"; public final String time; private final LocalDateTime localDateTime; @@ -49,38 +47,8 @@ public Time(LocalDateTime timeObject) { * @throws DateTimeParseException If the input string cannot be parsed into a valid LocalDateTime. */ private static LocalDateTime parseDate(String date) { - - DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("M/d/yyyy HHmm"); - DateTimeFormatter formatter2 = new DateTimeFormatterBuilder() - .appendPattern("M/d/yyyy") - .parseDefaulting(ChronoField.HOUR_OF_DAY, 0) - .parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0) - .parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0) - .toFormatter(); - DateTimeFormatter formatter3 = new DateTimeFormatterBuilder() - .appendPattern("yyyy-MM-dd") - .parseDefaulting(ChronoField.HOUR_OF_DAY, 0) - .parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0) - .parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0) - .toFormatter(); - DateTimeFormatter formatter4 = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"); - DateTimeFormatter formatter5 = new DateTimeFormatterBuilder() - .appendPattern("MMM d yyyy") - .parseDefaulting(ChronoField.HOUR_OF_DAY, 0) - .parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0) - .parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0) - .toFormatter(); - DateTimeFormatter formatter6 = DateTimeFormatter.ofPattern("EEEE, MMMM, dd, yyyy - hh:mm a"); - DateTimeFormatter[] formatters = {formatter1, formatter2, formatter3, formatter4, formatter5, formatter6}; - - for (DateTimeFormatter dateFormat : formatters) { - try { - return LocalDateTime.parse(date, dateFormat); - } catch (DateTimeParseException e) { - // Parsing failed for this pattern, try the next one - } - } - throw new DateTimeParseException("Failed to parse date string: " + date, date, 0); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEEE, MMMM, dd, yyyy - hh:mm a"); + return LocalDateTime.parse(date, formatter); } /** * Converts the given LocalDateTime object into a string representation diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/person/Name.java index 173f15b9b00..47c28629694 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/person/Name.java @@ -28,6 +28,7 @@ public class Name { public Name(String name) { requireNonNull(name); checkArgument(isValidName(name), MESSAGE_CONSTRAINTS); + name = name.replaceAll("\\s+", " "); fullName = name; } @@ -37,8 +38,6 @@ public Name(String name) { public static boolean isValidName(String test) { return test.matches(VALIDATION_REGEX); } - - @Override public String toString() { return fullName; @@ -56,7 +55,7 @@ public boolean equals(Object other) { } Name otherName = (Name) other; - return fullName.equals(otherName.fullName); + return fullName.equalsIgnoreCase(otherName.fullName); } @Override diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index a0a15529345..467c4f9d6c4 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -40,13 +40,14 @@ public void isSamePerson() { .withNextOfKin(VALID_NOK_BOB).withTags(VALID_TAG_HUSBAND).build(); assertTrue(ALICE.isSamePerson(updatedAlice)); + // name differs in case, all other attributes same -> returns true + Person updatedBob = new PersonBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); + assertTrue(BOB.isSamePerson(updatedBob)); + // different name, all other attributes same -> returns false updatedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build(); assertFalse(ALICE.isSamePerson(updatedAlice)); - // name differs in case, all other attributes same -> returns false - Person updatedBob = new PersonBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); - assertFalse(BOB.isSamePerson(updatedBob)); // name has trailing spaces, all other attributes same -> returns false String nameWithTrailingSpaces = VALID_NAME_BOB + " ";