Skip to content

Commit

Permalink
Merge pull request #50 from RuijianLu/branch-AddComments
Browse files Browse the repository at this point in the history
Add comment class for enabling adding comments to customers later
  • Loading branch information
RuijianLu authored Oct 10, 2024
2 parents d2176ec + 219cf2b commit b24eaa1
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/main/java/seedu/address/model/person/Comment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package seedu.address.model.person;

import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.AppUtil.checkArgument;

/**
* Represents a Person's comment the user made in the address book.
*/
public class Comment {

public static final String MESSAGE_CONSTRAINTS =
"comments should only contain alphanumeric characters and spaces, and it should not be blank";

public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*";
public final String fullComment;

/**
* Constructs a {@code Comment}.
*
* @param comment A valid comment.
*/
public Comment(String comment) {
requireNonNull(comment);
checkArgument(isValidComment(comment), MESSAGE_CONSTRAINTS);
fullComment = comment;
}

/**
* Returns true if a given string is a valid comment.
*/
public static boolean isValidComment(String test) {
return test.matches(VALIDATION_REGEX);
}

@Override
public String toString() {
return fullComment;
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof Name)) {
return false;
}

Name otherName = (Name) other;
return fullComment.equals(otherName.fullName);
}

@Override
public int hashCode() {
return fullComment.hashCode();
}

}

0 comments on commit b24eaa1

Please sign in to comment.