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.

50 lines
990 B

  1. /*
  2. * SD2x Homework #3
  3. * This class represents a single sentence.
  4. * Please do not change this code! Your solution will be evaluated using this version of the class.
  5. */
  6. public class Sentence implements Comparable<Sentence> {
  7. protected int score;
  8. protected String text;
  9. public Sentence(int score, String text) {
  10. this.score = score;
  11. this.text = text;
  12. }
  13. public int getScore() {
  14. return score;
  15. }
  16. public String getText() {
  17. return text;
  18. }
  19. @Override
  20. public boolean equals(Object obj) {
  21. if (this == obj)
  22. return true;
  23. if (obj == null)
  24. return false;
  25. if (getClass() != obj.getClass())
  26. return false;
  27. Sentence other = (Sentence) obj;
  28. if (score != other.score)
  29. return false;
  30. if (text == null) {
  31. if (other.text != null)
  32. return false;
  33. } else if (!text.equals(other.text))
  34. return false;
  35. return true;
  36. }
  37. @Override
  38. public int compareTo(Sentence o) {
  39. return this.score - o.score;
  40. }
  41. }