Java Reference
In-Depth Information
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.102 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;
28. }
29. }
Example A.103 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.104 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. }
DataCreator and FileLoader are used to create a sample set of Appointment objects, and to manage their
storage and retrieval from a file.
Example A.105 DataCreator.java
1. import java.io.Serializable;
2. import java.io.ObjectOutputStream;
3. import java.io.FileOutputStream;
4. import java.io.IOException;
5. import java.util.Calendar;
6. import java.util.Date;
7. import java.util.ArrayList;
Search WWH ::




Custom Search