SHARE
TWEET

Untitled

advictoriam Jan 31st, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.    Describes a person who will receive mail.
  3. */
  4. public class Person
  5. {
  6.    /*
  7.       TODO: To increase cohesion, reimplement this class by using
  8.       the Address class. Do not modify the main method that is used
  9.       for checking.
  10.    */
  11.    
  12.    /**
  13.       Constructs a person.
  14.       @param aName the person's name
  15.       @param aStreet the street
  16.       @param aCity the city
  17.       @param aState the two-letter state code
  18.       @param aZip the ZIP postal code
  19.    */
  20.    
  21.    private Address address;
  22.    private String name;
  23.    
  24.    public Person(String aName, Address a)
  25.    {  
  26.       name = aName;
  27.       address = a;
  28.    }  
  29.  
  30.    /**
  31.       Formats the person's name and address for mailing.
  32.       @return a string suitable for printing on a mailing label
  33.    */
  34.    public String formatForMailing()
  35.    {  
  36.       return String.format("%s\n%s", name, address.format());
  37.    }
  38.    
  39.    // This method is used for checking your work. Do not modify it
  40.  
  41.    public static void main(String[] args)
  42.    {
  43.       Person harry = new Person("Harold J. Hacker",
  44.          new Address("123 Main Street", "Anytown", "NY", "12345"));
  45.       System.out.println(harry.formatForMailing());
  46.    }  
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top