previous | start | next

File Address.java

1 /**
2     Describes a mailing address.
3 */
4 class Address
5 {  
6    /**
7        Constructs a mailing address. 
8       @param aName the recipient name
9       @param aStreet the street
10       @param aCity the city
11       @param aState the 2-letter state code
12       @param aZip the ZIP postal code
13     */
14    public Address(String aName, String aStreet,
15       String aCity, String aState, String aZip)
16    {  
17       name = aName;
18       street = aStreet;
19       city = aCity;
20       state = aState;
21       zip = aZip;
22    }   
23
24    /**
25        Formats the address.
26       @return the address as a string with 3 lines
27     */
28    public String format()
29    {  
30       return name + "\n" + street + "\n"
31          + city + ", " + state + " " + zip;
32    }
33    
34    private String name;
35    private String street;
36    private String city;
37    private String state;
38    private String zip;
39 }
40


previous | start | next