-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify dateOfLastVisit to use LocalDate instead of String #171
Changes from 8 commits
2d3b0c6
4e7819e
89a8b80
78f80a8
25918eb
36dd2cb
dbdb521
9615125
6ea4803
893b074
dadada2
2d94b14
0d887ed
8a43459
2bfc17e
81b3dba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package seedu.address.model.person; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Comparator; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
|
@@ -12,7 +13,7 @@ public class PersonComparator { | |
public static final String NAME = "name"; | ||
public static final String DATE_OF_LAST_VISIT = "date of last visit"; | ||
public static final String EARLIEST_VALID_DATE = "01-01-0001"; | ||
public static final String LATEST_VALID_DATE = "31-12-9999"; | ||
public static final String LATEST_VALID_DATE = LocalDate.now().format(DateOfLastVisit.DATE_TIME_FORMATTER); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be better to not change this. The LATEST_VALID_DATE is meant to distinguish entries with no date of last visit from those that do have. I believe in this case if you set the date of last visit to be today for one of the entries and then sort the entry with dolv as today will be mixed with those without date of last visit. Hence, it is better to keep the value as is or to set it as today + 1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DateOfLastVisit has been updated to accept a date no later than today, which means that a date of "31-12-9999" would not be possible. I have updated the comparators for date of last visit to not use EARLIEST_VALID_DATE and LATEST_VALID_DATE. Although this makes the code slightly longer and less clean, the functionality works as expected. |
||
private static final String SORT_EXCEPTION = "The specified parameter is invalid."; | ||
|
||
public PersonComparator() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
"email" : "[email protected]", | ||
"address" : "wall street", | ||
"tags" : [ ], | ||
"dateOfLastVisit" : "01-01-2025", | ||
"dateOfLastVisit" : "01-04-2024", | ||
"emergencyContact" : "", | ||
"remark" : "" | ||
}, { | ||
|
@@ -33,7 +33,7 @@ | |
"email" : "[email protected]", | ||
"address" : "10th street", | ||
"tags" : [ "friends" ], | ||
"dateOfLastVisit" : "02-01-2024", | ||
"dateOfLastVisit" : "02-04-2024", | ||
"emergencyContact" : "", | ||
"remark" : "" | ||
}, { | ||
|
@@ -42,7 +42,7 @@ | |
"email" : "[email protected]", | ||
"address" : "michegan ave", | ||
"tags" : [ ], | ||
"dateOfLastVisit" : "10-10-2024", | ||
"dateOfLastVisit" : "10-07-2024", | ||
"emergencyContact" : "", | ||
"remark" : "" | ||
}, { | ||
|
@@ -60,7 +60,7 @@ | |
"email" : "[email protected]", | ||
"address" : "4th street", | ||
"tags" : [ ], | ||
"dateOfLastVisit" : "05-06-2024", | ||
"dateOfLastVisit" : "05-09-2024", | ||
"emergencyContact" : "", | ||
"remark" : "" | ||
} ] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,19 +37,19 @@ public class TypicalPersons { | |
.withTags("owesMoney", "friends").withDateOfLastVisit("01-02-2024") | ||
.withEmergencyContact("92173902").build(); | ||
public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") | ||
.withEmail("[email protected]").withAddress("wall street").withDateOfLastVisit("01-01-2025") | ||
.withEmail("[email protected]").withAddress("wall street").withDateOfLastVisit("01-04-2024") | ||
.withEmergencyContact().build(); | ||
public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") | ||
.withEmail("[email protected]").withAddress("10th street").withTags("friends") | ||
.withDateOfLastVisit("02-01-2024").withEmergencyContact().build(); | ||
.withDateOfLastVisit("02-04-2024").withEmergencyContact().build(); | ||
public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("94822249") | ||
.withEmail("[email protected]").withAddress("michegan ave").withDateOfLastVisit("10-10-2024") | ||
.withEmail("[email protected]").withAddress("michegan ave").withDateOfLastVisit("10-07-2024") | ||
.withEmergencyContact().build(); | ||
public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("94824270") | ||
.withEmail("[email protected]").withAddress("little tokyo").withDateOfLastVisit("23-08-2024") | ||
.withEmergencyContact().build(); | ||
public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("94824421") | ||
.withEmail("[email protected]").withAddress("4th street").withDateOfLastVisit("05-06-2024") | ||
.withEmail("[email protected]").withAddress("4th street").withDateOfLastVisit("05-09-2024") | ||
.withEmergencyContact().build(); | ||
|
||
// Manually added | ||
|
@@ -127,10 +127,10 @@ public static List<Person> getTypicalPersonsDescendingName() { | |
} | ||
|
||
public static List<Person> getTypicalPersonsAscendingDateOfLastVisit() { | ||
return new ArrayList<>(Arrays.asList(ALICE, DANIEL, BENSON, GEORGE, FIONA, ELLE, CARL)); | ||
return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); | ||
rayray39 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public static List<Person> getTypicalPersonsDescendingDateOfLastVisit() { | ||
return new ArrayList<>(Arrays.asList(CARL, ELLE, FIONA, GEORGE, BENSON, DANIEL, ALICE)); | ||
return new ArrayList<>(Arrays.asList(GEORGE, FIONA, ELLE, DANIEL, CARL, BENSON, ALICE)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand the ensure month is 01-12 comment. Do you mean ensure that month is after day?
Edit: Oh I think you mean ensure the month is typed with 2 digits, but I think you can take this as a given since we requested dd-MM-yyyy format. You can say "Date of Last Visit should be in exactly dd-MM-yyyy format. Also it is good to add an example in the error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup that was the intention and i will update the error message as suggested