-
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
Add Postal Code #55
Add Postal Code #55
Changes from all commits
c9f8387
56b2ca1
fad6da1
8267b80
052fa4a
2981bda
684b1bd
9ce3307
81313f1
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 |
---|---|---|
|
@@ -56,7 +56,7 @@ public class EditCommand extends Command { | |
private final EditPersonDescriptor editPersonDescriptor; | ||
|
||
/** | ||
* @param index of the person in the filtered person list to edit | ||
* @param index of the person in the filtered person list to edit | ||
* @param editPersonDescriptor details to edit the person with | ||
*/ | ||
public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { | ||
|
@@ -101,7 +101,8 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript | |
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); | ||
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); | ||
|
||
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); | ||
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, | ||
personToEdit.getPostalCode(), updatedTags); | ||
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.
But isn't this edit command? 😅😅 I don't think you have to touch this. 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. Yeap, I set it to be like this because I have not officially change the edit function yet for postal code. I think if I did not make any changes to the edit, the test cases for the edit will not pass, and hence the build will not go through at the GitHub. The current edit implementation is just temporary, I will edit this when I doing the next iteration. But yes, thanks for noticing and bringing it up :) |
||
} | ||
|
||
@Override | ||
|
@@ -139,7 +140,8 @@ public static class EditPersonDescriptor { | |
private Address address; | ||
private Set<Tag> tags; | ||
|
||
public EditPersonDescriptor() {} | ||
public EditPersonDescriptor() { | ||
} | ||
|
||
/** | ||
* Copy constructor. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ public class CliSyntax { | |
public static final Prefix PREFIX_EMAIL = new Prefix("e/"); | ||
public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); | ||
public static final Prefix PREFIX_TAG = new Prefix("t/"); | ||
public static final Prefix PREFIX_POSTALCODE = new Prefix("postal/"); | ||
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. Perhaps using 'pc/' instead of 'postal/' would allow users to type faster? |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package seedu.address.model.house; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents a House's postal code in the address book. | ||
* Guarantees: immutable; is valid as declared in {@link #isValidPostalCode(String)} | ||
*/ | ||
public class PostalCode { | ||
|
||
public static final String MESSAGE_CONSTRAINTS = | ||
"The postal code should only contain numbers, and it should be only 6 digits long"; | ||
public static final String VALIDATION_REGEX = "\\d{6}"; | ||
public final String value; | ||
|
||
/** | ||
* Constructs a {@code PostalCode}. | ||
* | ||
* @param postalCode A valid postal code. | ||
*/ | ||
public PostalCode(String postalCode) { | ||
requireNonNull(postalCode); | ||
checkArgument(isValidPostalCode(postalCode), MESSAGE_CONSTRAINTS); | ||
value = postalCode; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid postal code. | ||
*/ | ||
public static boolean isValidPostalCode(String test) { | ||
return test.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
if (!(other instanceof PostalCode)) { | ||
return false; | ||
} | ||
|
||
PostalCode otherPostalCode = (PostalCode) other; | ||
return value.equals(otherPostalCode.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
} | ||
|
||
} |
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.
Should the extra space be removed?