Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. package WS1617.Aufgabe1;
  2.  
  3. import java.util.Objects;
  4.  
  5. /**
  6. * Created by Armin on 09.06.2017.
  7. */
  8. public abstract class BaseOpus implements Opus {
  9.  
  10. private final int yearCreated;
  11. private final String title;
  12.  
  13. protected BaseOpus (int yearCreated, String title){
  14. this.yearCreated = yearCreated;
  15. this.title = title;
  16. }
  17.  
  18. @Override
  19. public int yearCreated(){
  20. return yearCreated;
  21. }
  22.  
  23.  
  24. @Override
  25. public String getTitle(){
  26. return title;
  27. }
  28.  
  29. public abstract double setValue();
  30.  
  31. public abstract double value();
  32.  
  33. // b;
  34.  
  35. @Override
  36. public String toString(){
  37. return "BaseOpus{" +
  38. "yearCreated= " + yearCreated() +
  39. "title= " + getTitle() +
  40. "}";
  41. }
  42.  
  43. @Override
  44. public boolean equals (Object x){
  45. if (this == x) return false; //same
  46. if (this == null) return false; //null
  47. if ((this.getClass() != x.getClass())) return false; //class
  48.  
  49. BaseOpus that = (BaseOpus) x; //typecast
  50.  
  51. if (this.yearCreated() != that.yearCreated()) return false;
  52. if (this.getTitle() != that.getTitle()) return false;
  53.  
  54. return true;
  55. }
  56.  
  57.  
  58. @Override
  59. public int hashCode(){
  60. int result = 3;
  61. result = 31 * result + yearCreated();
  62. result = 31 * result + getTitle().hashCode();
  63. return result;
  64. }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement