Skip to content

Commit

Permalink
Add new method to support changing details of a Person
Browse files Browse the repository at this point in the history
 (not yet implementing)
  • Loading branch information
blackpanther9229 committed Oct 10, 2024
1 parent 04e2b8c commit 6ee0d49
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/main/java/seedu/address/model/person/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Address {
*/
public static final String VALIDATION_REGEX = "[^\\s].*";

public final String value;
public String value;

/**
* Constructs an {@code Address}.
Expand All @@ -30,6 +30,12 @@ public Address(String address) {
value = address;
}

public void changeAddress(String address) {
requireNonNull(address);
checkArgument(isValidAddress(address), MESSAGE_CONSTRAINTS);
value = address;
}

/**
* Returns true if a given string is a valid email.
*/
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/seedu/address/model/person/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Email {
private static final String DOMAIN_REGEX = "(" + DOMAIN_PART_REGEX + "\\.)*" + DOMAIN_LAST_PART_REGEX;
public static final String VALIDATION_REGEX = LOCAL_PART_REGEX + "@" + DOMAIN_REGEX;

public final String value;
public String value;

/**
* Constructs an {@code Email}.
Expand All @@ -44,6 +44,12 @@ public Email(String email) {
value = email;
}

public void changeEmail(String email) {
requireNonNull(email);
checkArgument(isValidEmail(email), MESSAGE_CONSTRAINTS);
value = email;
}

/**
* Returns if a given string is a valid email.
*/
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/seedu/address/model/person/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Name {
*/
public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*";

public final String fullName;
public String fullName;

/**
* Constructs a {@code Name}.
Expand All @@ -31,6 +31,12 @@ public Name(String name) {
fullName = name;
}

public void changeName(String name) {
requireNonNull(name);
checkArgument(isValidName(name), MESSAGE_CONSTRAINTS);
fullName = name;
}

/**
* Returns true if a given string is a valid name.
*/
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ public int hashCode() {
return Objects.hash(name, phone, email, address, tags);
}

public void changeName(String newName) {
name.changeName(newName);
}

public void changePhoneNumber(String newNumber) {
phone.changePhoneNumber(newNumber);
}

public void changeEmail(String newEmail) {
email.changeEmail(newEmail);
}

public void changeAddress(String newAddress) {
address.changeAddress(newAddress);
}

@Override
public String toString() {
return new ToStringBuilder(this)
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/seedu/address/model/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Phone {
public static final String MESSAGE_CONSTRAINTS =
"Phone numbers should only contain numbers, and it should be at least 3 digits long";
public static final String VALIDATION_REGEX = "\\d{3,}";
public final String value;
public String value;

/**
* Constructs a {@code Phone}.
Expand All @@ -26,6 +26,12 @@ public Phone(String phone) {
value = phone;
}

public void changePhoneNumber(String phone) {
requireNonNull(phone);
checkArgument(isValidPhone(phone), MESSAGE_CONSTRAINTS);
value = phone;
}

/**
* Returns true if a given string is a valid phone number.
*/
Expand Down

0 comments on commit 6ee0d49

Please sign in to comment.