Java Reference
In-Depth Information
8.
9. public AppointmentImpl(String newDescription, ArrayList newAttendees,
10. Location newLocation, Date newStartDate){
11. description = newDescription;
12. attendees = newAttendees;
13. location = newLocation;
14. startDate = newStartDate;
15. }
16.
17. public Date getStartDate(){ return startDate; }
18. public String getDescription(){ return description; }
19. public ArrayList getAttendees(){ return attendees; }
20. public Location getLocation(){ return location; }
21.
22. public void setDescription(String newDescription){ description = newDescription; }
23. public void setLocation(Location newLocation){ location = newLocation; }
24. public void setStartDate(Date newStartDate){ startDate = newStartDate; }
25. public void setAttendees(ArrayList newAttendees){
26. if (newAttendees != null){
27. attendees = newAttendees;
28. }
29. }
30.
31. public void addAttendee(Contact attendee){
32. if (!attendees.contains(attendee)){
33. attendees.add(attendee);
34. }
35. }
36.
37. public void removeAttendee(Contact attendee){
38. attendees.remove(attendee);
39. }
40.
41. public int hashCode(){
42. return description.hashCode() ^ startDate.hashCode();
43. }
44.
45. public boolean equals(Object object){
46. if (!(object instanceof AppointmentImpl)){
47. return false;
48. }
49. if (object.hashCode() != hashCode()){
50. return false;
51. }
52. return true;
53. }
54.
55. public String toString(){
56. return " Description: " + description + EOL_STRING +
57. " Start Date: " + startDate + EOL_STRING +
58. " Location: " + location + EOL_STRING +
59. " Attendees: " + attendees;
60. }
61. }
Example A.259 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.260 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.
Search WWH ::




Custom Search