package cart; import cart.utils.ValidationUtils; //Phone - has methods to store phone numbers //author - Lawrence Truett - FluffyCat.com //date - August 12, 2003 - San Diego, CA public class Phone { private String rawPhone = null; private String errorString = null; public Phone() {} public Phone(String phoneIn) { this.setPhone(phoneIn); } public static String getElement() { return "Phone Number"; } //for now just store raw phone number as passed in public String getPhone() {return rawPhone;} private void setPhone(String phoneIn) { this.rawPhone = phoneIn; } private String getErrorString() {return errorString;} private void setErrorString(String errorStringIn) { this.errorString = errorStringIn; } //very basic phone edits - how should phone be edited? public boolean isValid() { if (this.getPhone().trim().length() > 7) { this.setErrorString("phone must be greter than 7 digits"); return true; } else { return false; } } //method used for data input public boolean isValidOrNull() { if ((ValidationUtils.isStringBlank(this.getPhone()))) { return true; } else { return this.isValid(); } } public String getErrorMessage() { if (this.isValid()) { return " "; } else { return this.getErrorString(); } } public String getErrorOrNullMessage() { if (ValidationUtils.isStringBlank(this.getPhone())) { return "Phone Number Is Blank"; } else { return this.getErrorMessage(); } } public String toString() {return ("phone: " + this.getPhone());} }