Java Reference
In-Depth Information
The interfaces Contact and Location , with their corresponding implementation classes ContactImpl and
LocationImpl , provide additional business objects used by the Appointment class.
Example A.46 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.47 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. public static final String EOL_STRING =
7. System.getProperty("line.separator");
8.
9. public ContactImpl(){ }
10. public ContactImpl(String newFirstName, String newLastName,
11. String newTitle, String newOrganization){
12. firstName = newFirstName;
13. lastName = newLastName;
14. title = newTitle;
15. organization = newOrganization;
16. }
17.
18. public String getFirstName(){ return firstName; }
19. public String getLastName(){ return lastName; }
20. public String getTitle(){ return title; }
21. public String getOrganization(){ return organization; }
22.
23. public void setFirstName(String newFirstName){ firstName = newFirstName; }
24. public void setLastName(String newLastName){ lastName = newLastName; }
25. public void setTitle(String newTitle){ title = newTitle; }
26. public void setOrganization(String newOrganization){ organization = newOrganization; }
27.
28. public String toString(){
29. return firstName + " " + lastName;
30. }
31. }
Example A.48 Location.java
1. import java.io.Serializable;
2. public interface Location extends Serializable{
3. public String getLocation();
4. public void setLocation(String newLocation);
5. }
Example A.49 LocationImpl.java
1. public class LocationImpl implements Location{
2. private String location;
3.
4. public LocationImpl(){ }
5. public LocationImpl(String newLocation){
6. location = newLocation;
7. }
8.
9. public String getLocation(){ return location; }
10.
11. public void setLocation(String newLocation){ location = newLocation; }
12.
13. public String toString(){ return location; }
14. }
Search WWH ::




Custom Search