Consider the Person class below.

Note how this class intermingles two responsibilities: describing a person, and formatting an address. The second responsibility is not trivial. We may want to add support for department names or apartment numbers. Addresses in other countries have entirely different formats.

Ideally, the Person class should have a single responsibility: to describe a person who has an address. A separate Address class should be responsible for the details of managing addresses.

Your task is to modify the Person class so that it uses the Address class given below. The main method shows how your modified class should be used.

Complete the following file:

Person.java

/** Describes a person who will receive mail. */ public class Person { /* TODO: To increase cohesion, reimplement this class by using the Address class. Do not modify the main method that is used for checking. */ /** Constructs a person. @param aName the person's name @param aStreet the street @param aCity the city @param aState the two-letter state code @param aZip the ZIP postal code */ public Person(String aName, String aStreet, String aCity, String aState, String aZip) { name = aName; street = aStreet; city = aCity; state = aState; zip = aZip; } /** Formats the person's name and address for mailing. @return a string suitable for printing on a mailing label */ public String formatForMailing() { return name + "\n" + street + "\n" + city + ", " + state + " " + zip; } private String name; private String street; private String city; private String state; private String zip; // This method is used for checking your work. Do not modify it public static void main(String[] args) { Person harry = new Person("Harold J. Hacker", new Address("123 Main Street", "Anytown", "NY", "12345")); System.out.println(harry.formatForMailing()); } }

Use the following file:

Address.java

/**
   Describes a mailing address.
*/
public class Address
{  
   /**
      Constructs a mailing address. 
      @param aStreet the street
      @param aCity the city
      @param aState the two-letter state code
      @param aZip the ZIP postal code
   */
   public Address(String aStreet, String aCity, String aState, String aZip)
   {  
      street = aStreet;
      city = aCity;
      state = aState;
      zip = aZip;
   }   

   /**
      Formats the address.
      @return a string containing the address in mailing list format
   */
   public String format()
   {  
      return street + "\n"
            + city + ", " + state + " " + zip;
   }
   
   private String street;
   private String city;
   private String state;
   private String zip;
}