KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > Address


1 package examples;
2
3 /**
4  * @author Ben Wang
5  */

6 public class Address {
7    protected String JavaDoc city;
8    protected int zip;
9    protected String JavaDoc street;
10
11    public void setCity(String JavaDoc city)
12    {
13       this.city = city;
14    }
15
16    public String JavaDoc getCity()
17    {
18       return this.city;
19    }
20
21    public void setZip(int zip)
22    {
23       this.zip = zip;
24    }
25
26    public int getZip()
27    {
28       return zip;
29    }
30
31    public void setStreet(String JavaDoc street)
32    {
33       this.street = street;
34    }
35
36    public String JavaDoc getStreet()
37    {
38       return this.street;
39    }
40    
41    public String JavaDoc getSimpleAddress()
42    {
43       StringBuffer JavaDoc buf = new StringBuffer JavaDoc(street);
44       buf.append(" " + city);
45       if (zip > 0)
46          buf.append(" " + zip);
47
48       return buf.toString();
49    }
50
51    public String JavaDoc toString()
52    {
53       StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
54       buf.append("{City = " +city).append(" ,zip = " +zip).append(" ,street = " +street + "}\n");
55
56       return buf.toString();
57    }
58 }
59
Popular Tags