Java Reference
In-Depth Information
Example A.184 Appointment.java
1. import java.io.Serializable;
2. import java.util.Date;
3. import java.util.ArrayList;
4. public class Appointment implements Serializable{
5. private String description;
6. private ArrayList contacts;
7. private Location location;
8. private Date startDate;
9. private Date endDate;
10.
11. public Appointment(String description, ArrayList contacts, Location location, Date
startDate, Date endDate){
12. this.description = description;
13. this.contacts = contacts;
14. this.location = location;
15. this.startDate = startDate;
16. this.endDate = endDate;
17. }
18.
19. public String getDescription(){ return description; }
20. public ArrayList getContacts(){ return contacts; }
21. public Location getLocation(){ return location; }
22. public Date getStartDate(){ return startDate; }
23. public Date getEndDate(){ return endDate; }
24.
25. public void setDescription(String description){ this.description = description; }
26. public void setContacts(ArrayList contacts){ this.contacts = contacts; }
27. public void setLocation(Location location){ this.location = location; }
28. public void setStartDate(Date startDate){ this.startDate = startDate; }
29. public void setEndDate(Date endDate){ this.endDate = endDate; }
30.
31. public String toString(){
32. return "Appointment:" + "\n Description: " + description +
33. "\n Location: " + location + "\n Start: " +
34. startDate + "\n End: " + endDate + "\n";
35. }
36. }
Example A.185 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.186 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; }
Search WWH ::




Custom Search