Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- 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
- */
- private Address address;
- private String name;
- public Person(String aName, Address a)
- {
- name = aName;
- address = a;
- }
- /**
- Formats the person's name and address for mailing.
- @return a string suitable for printing on a mailing label
- */
- public String formatForMailing()
- {
- return String.format("%s\n%s", name, address.format());
- }
- // 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());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement