Java Reference
In-Depth Information
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.224 Contact.java
1. import java.io.Serializable;
2. public interface Contact extends Serializable{
3. public static final String EOL_STRING = System.getProperty("line.separator");
4. public static final String SPACE = " ";
5. public String getFirstName();
6. public String getLastName();
7. public String getTitle();
8. public String getOrganization();
9.
10. public void setFirstName(String newFirstName);
11. public void setLastName(String newLastName);
12. public void setTitle(String newTitle);
13. public void setOrganization(String newOrganization);
14. }
Example A.225 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; }
25.
26. public String toString(){
27. return firstName + SPACE + lastName + EOL_STRING;
28. }
29. }
RunPattern creates a ConcreteQueue , then uses it to retrieve a sample Contact and two Addresses . The worker
thread in the queue processes these requests as they are added to the queue. The ConcreteQueue and its
associated worker thread can be used throughout the lifetime of a client application, performing any background
task required by the client as RunnableTask objects are added to its queue.
Search WWH ::




Custom Search