Java Reference
In-Depth Information
6. public String getType();
7. public String getDescription();
8. public String getStreet();
9. public String getCity();
10. public String getState();
11. public String getZipCode();
12.
13. public void setType(String newType);
14. public void setDescription(String newDescription);
15. public void setStreet(String newStreet);
16. public void setCity(String newCity);
17. public void setState(String newState);
18. public void setZipCode(String newZip);
19. }
Example A.85 AddressImpl.java
1. public class AddressImpl implements Address{
2. private String type;
3. private String description;
4. private String street;
5. private String city;
6. private String state;
7. private String zipCode;
8.
9. public AddressImpl(){ }
10. public AddressImpl(String newDescription, String newStreet,
11. String newCity, String newState, String newZipCode){
12. description = newDescription;
13. street = newStreet;
14. city = newCity;
15. state = newState;
16. zipCode = newZipCode;
17. }
18.
19. public String getType(){ return type; }
20. public String getDescription(){ return description; }
21. public String getStreet(){ return street; }
22. public String getCity(){ return city; }
23. public String getState(){ return state; }
24. public String getZipCode(){ return zipCode; }
25.
26. public void setType(String newType){ type = newType; }
27. public void setDescription(String newDescription){ description = newDescription; }
28. public void setStreet(String newStreet){ street = newStreet; }
29. public void setCity(String newCity){ city = newCity; }
30. public void setState(String newState){ state = newState; }
31. public void setZipCode(String newZip){ zipCode = newZip; }
32.
33. public String toString(){
34. return street + EOL_STRING + city + COMMA + SPACE +
35. state + SPACE + zipCode + EOL_STRING;
36. }
37. }
Example A.86 Contact.java
1. import java.io.Serializable;
2. public interface Contact extends Serializable{
3. public static final String SPACE = " ";
4. public String getFirstName();
5. public String getLastName();
6. public String getTitle();
7. public String getOrganization();
8.
9. public void setFirstName(String newFirstName);
10. public void setLastName(String newLastName);
11. public void setTitle(String newTitle);
12. public void setOrganization(String newOrganization);
13. }
Example A.87 ContactImpl.java
1. public class ContactImpl implements Contact{
2. private String firstName;
3. private String lastName;
4. private String title;
5. private String organization;
6. private Address address;
Search WWH ::




Custom Search