Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Second part is the Person Class...I have the other Classes AddressBookLauncher,

ID: 645704 • Letter: S

Question

Second part is the Person Class...I have the other Classes AddressBookLauncher, ValidationException and PersonFullNameComparator finished. its just the Person CLass and AddressBook Class I need help with

Here is the Code...

public class Person {

   // Declare variables
   private String fullName;
   private String phoneNumber;
   private String email;
  
   // Default constructor
   public Person() {
       fullName = "unknown";
       phoneNumber = "unknown";
       email = "unknown";
   }
  
   public Person(String fullName, String phoneNumber, String email){
       this.fullName = fullName;
       this.phoneNumber = phoneNumber;
       this.email = email;
   }
  
   public String getFullName(){
       return fullName;
   }
  
   public void setFullName(String fullName) throws ValidationException{
       validateString(fullName, "fullName", 50);
       this.fullName = fullName;
   }
  
   public String getPhoneNumber(){
       return phoneNumber;
   }
  
   public void setPhoneNumber(String phoneNumber) throws ValidationException{
       validateString(phoneNumber, "phoneNumber", 15);
       this.phoneNumber = phoneNumber;
   }
  
   public String getEmail(){
       return email;
   }
  
   public void setEmail(String email) throws ValidationException{
       validateString(email, "email", 35);
       this.email = email;
   }
  
   public String toString(){
       return String.format("%s %s %s", fullName, phoneNumber, email);
   }
  
   public static void validateString(String value, String fieldName, int maxLength) throws ValidationException
   {
   if(fieldName.equals("fullName"))
   {
   if(value == null || value.equals("") || value.length() > maxLength)
   throw new ValidationException("Full Name cannot be empty");
     
   int spacesCount = value.length() - value.replace(" ", "").length();
   int commaCount = value.length() - value.replace(",", "").length();
     
   if(value.length() == spacesCount || commaCount > 0)
   throw new ValidationException("Full Name cannot be empty");
   }
  
   if(fieldName.equals("phoneNumber"))
   {
   if(value == null || value.equals("") || value.length() > maxLength)
   throw new ValidationException("Phone number cannot be empty");
     
   int spacesCount = value.length() - value.replace(" ", "").length();
   int commaCount = value.length() - value.replace(",", "").length();
     
   if(value.length() == spacesCount || commaCount > 0)
   throw new ValidationException("Phone number cannot be empty");
   }
  
   if(fieldName.equals("email"))
   {
   if(value == null || value.equals("") || value.length() > maxLength)
   throw new ValidationException("Email cannot be empty");
     
   int spacesCount = value.length() - value.replace(" ", "").length();
   int commaCount = value.length() - value.replace(",", "").length();
     
   if(value.length() == spacesCount || commaCount > 0)
   throw new ValidationException("Email cannot be empty");
   }
   }

}

ValidationException Class

public class ValidationException extends Exception {
  
   ValidationException()
   {
   super("Data not in correct format");
   }
  
   ValidationException(String detail) {
   super(detail);
   }
  
   ValidationException(String detail,Throwable t) {
   super(detail,t);
   }
  
   ValidationException(Throwable t) {
   super(t);
   }

}

OUTPUT NEEDED IS IN THE FOLLOWING QUESTION....

Recommended Readings on UML: Donald Bell (2004), UML basics: The class diagram. Retrieved from http:/wwwibmcom/developerworks/rational/library/content/RationalEdge/sep04/bell/WN1005, Kirill Fakhroutdinov. (2014). Class Diagrams. Retrieved from http://wwwuml-diagrams.org/class-diagrams.html ippias Minor. (2013, stackoverflow Is there a specific notation for a final static class in UMLP Retrieved from http:/stackoverflow.com/questions/1265638/is. here-a-specific tation-for-a-final-static-class-in-uml Strine phoneNumber Stringems String Narely series retuiNet IN reePhone Number Suring setPhone Numberphone Number Suring sold gettmaia string lengefensivalue Strees felta Strina, malength in): Vols alidationException ValidationException message: String ValidationException messageString, throwable Throwabl Validation Exception(throwable: Throwable Simple Class • Has three fields, full name, phone number, email • Two constructors, both "throws ValidationException • Defaul constructor should set all fields to "unknown " • Gets and Sets for the fields • Each Set can "throws Validation Exception • validateString method, static and will throw ValidationExceptions with an appropriate message based on arguments sent to parameters, • Note: throw validation exceptions fulIName cannot be null or empty or only whitespace and cannot exceed 50 characters. phone Number cannot be nul or empty or only whitespace and cannot exceed 15 characters, email cannot be null or empty or only whitespace and cannot exceed 35 characters. None of the fields should contain a comma character. toString) should return fullName, phoneNumber, and email separated by commas. Using either a stringBuilder or string forma is acceptable. • This extends class java.langException • There are 4 constructors The default constructor should use the super class constructor to set a message like: "Data not in valid format The other constructors should pass their parameters into appropriate super class constructors PersonFullNameComparator comparear argo: Person, arg1: Person: int ddressBookLauncher • This class implements java .util .Comparator • The code is provided in the handout • method compare returns an int Less than zero means that argo is smaller than arg1 (typically -1) • Zero means that argo and argi are the same value • Greater than zero means that argo is larger than arg1 (typically 1 We don't use the return values ourselves, but they will be used by the CollectionsSort(Collection, Comparator) method. This class has method the program, main which starts the code is provided at the end of the handout mainlargsStrine : void

Explanation / Answer

public class Person {

   // Declare variables
   private String fullName;
   private String phoneNumber;
   private String email;
  
   // Default constructor
   public Person() {
       fullName = "unknown";
       phoneNumber = "unknown";
       email = "unknown";
   }
  
   public Person(String fullName, String phoneNumber, String email){
       this.fullName = fullName;
       this.phoneNumber = phoneNumber;
       this.email = email;
   }
  
   public String getFullName(){
       return fullName;
   }
  
   public void setFullName(String fullName) throws ValidationException{
       validateString(fullName, "fullName", 50);
       this.fullName = fullName;
   }
  
   public String getPhoneNumber(){
       return phoneNumber;
   }
  
   public void setPhoneNumber(String phoneNumber) throws ValidationException{
       validateString(phoneNumber, "phoneNumber", 15);
       this.phoneNumber = phoneNumber;
   }
  
   public String getEmail(){
       return email;
   }
  
   public void setEmail(String email) throws ValidationException{
       validateString(email, "email", 35);
       this.email = email;
   }
  
   public String toString(){
       return String.format("%s %s %s", fullName, phoneNumber, email);
   }
  
   public static void validateString(String value, String fieldName, int maxLength) throws ValidationException
   {
   if(fieldName.equals("fullName"))
   {
   if(value == null || value.equals("") || value.length() > maxLength)
   throw new ValidationException("Full Name cannot be empty");
     
   int spacesCount = value.length() - value.replace(" ", "").length();
   int commaCount = value.length() - value.replace(",", "").length();
     
   if(value.length() == spacesCount || commaCount > 0)
   throw new ValidationException("Full Name cannot be empty");
   }
  
   if(fieldName.equals("phoneNumber"))
   {
   if(value == null || value.equals("") || value.length() > maxLength)
   throw new ValidationException("Phone number cannot be empty");
     
   int spacesCount = value.length() - value.replace(" ", "").length();
   int commaCount = value.length() - value.replace(",", "").length();
     
   if(value.length() == spacesCount || commaCount > 0)
   throw new ValidationException("Phone number cannot be empty");
   }
  
   if(fieldName.equals("email"))
   {
   if(value == null || value.equals("") || value.length() > maxLength)
   throw new ValidationException("Email cannot be empty");
     
   int spacesCount = value.length() - value.replace(" ", "").length();
   int commaCount = value.length() - value.replace(",", "").length();
     
   if(value.length() == spacesCount || commaCount > 0)
   throw new ValidationException("Email cannot be empty");
   }
   }

}

ValidationException Class

public class ValidationException extends Exception {
  
   ValidationException()
   {
   super("Data not in correct format");
   }
  
   ValidationException(String detail) {
   super(detail);
   }
  
   ValidationException(String detail,Throwable t) {
   super(detail,t);
   }
  
   ValidationException(Throwable t) {
   super(t);
   }

}

class PersonFullNameComparator

{public int compare(arg0:Person,arg1:Person)

{if(arg0==arg1)

return 0;

elseif(arg0

return -1;

elseif(arg0>arg1)

return 1;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote