This repository acts as a personal archive for my solutions to EdX course *Data Structures and Software Design* from PennX.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

  1. import java.util.Date;
  2. import java.util.Set;
  3. import java.util.HashSet;
  4. public abstract class Document {
  5. private String title;
  6. private String author;
  7. private Date date;
  8. private PublishingLocation publishingLocation;
  9. public Document(String title, String author, Date date, String city, String state, String postCode){
  10. this.title = title;
  11. this.author = author;
  12. this.date = date;
  13. this.publishingLocation = new PublishingLocation(city, state, postCode);
  14. }
  15. public String getTitle() {
  16. return title;
  17. }
  18. public String getAuthor() {
  19. return author;
  20. }
  21. public Date getDate() {
  22. return date;
  23. }
  24. public boolean sameAuthor(Document article){
  25. return this.author.equals(article.author);
  26. }
  27. public int compareDates(Document article){
  28. return this.date.compareTo(article.date);
  29. }
  30. public int compareWithGeneralDate(Date date){
  31. return this.date.compareTo(date);
  32. }
  33. public String getCity() {
  34. return publishingLocation.getCity();
  35. }
  36. public String getState() {
  37. return publishingLocation.getState();
  38. }
  39. public String getPostCode() {
  40. return publishingLocation.getPostCode();
  41. }
  42. }