Java Reference
In-Depth Information
4. private String street;
5. private String city;
6. private String state;
7. private String zipCode;
8. public static final String HOME = "home";
9. public static final String WORK = "work";
10.
11. public AddressImpl(){ }
12. public AddressImpl(String newDescription, String newStreet,
13. String newCity, String newState, String newZipCode){
14. description = newDescription;
15. street = newStreet;
16. city = newCity;
17. state = newState;
18. zipCode = newZipCode;
19. }
20.
21. public String getType(){ return type; }
22. public String getDescription(){ return description; }
23. public String getStreet(){ return street; }
24. public String getCity(){ return city; }
25. public String getState(){ return state; }
26. public String getZipCode(){ return zipCode; }
27.
28. public void setType(String newType){ type = newType; }
29. public void setDescription(String newDescription){ description = newDescription; }
30. public void setStreet(String newStreet){ street = newStreet; }
31. public void setCity(String newCity){ city = newCity; }
32. public void setState(String newState){ state = newState; }
33. public void setZipCode(String newZip){ zipCode = newZip; }
34.
35. public String toString(){
36. return street + EOL_STRING + city + COMMA + SPACE +
37. state + SPACE + zipCode + EOL_STRING;
38. }
39. }
Example A.178 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.179 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.
7. public ContactImpl(){}
8. public ContactImpl(String newFirstName, String newLastName,
9. String newTitle, String newOrganization){
10. firstName = newFirstName;
11. lastName = newLastName;
12. title = newTitle;
13. organization = newOrganization;
14. }
15.
16. public String getFirstName(){ return firstName; }
17. public String getLastName(){ return lastName; }
18. public String getTitle(){ return title; }
19. public String getOrganization(){ return organization; }
20.
21. public void setFirstName(String newFirstName){ firstName = newFirstName; }
22. public void setLastName(String newLastName){ lastName = newLastName; }
23. public void setTitle(String newTitle){ title = newTitle; }
24. public void setOrganization(String newOrganization){ organization = newOrganization; }
Search WWH ::




Custom Search