Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package WS1617.Aufgabe1;
- import java.util.Objects;
- /**
- * Created by Armin on 09.06.2017.
- */
- public abstract class BaseOpus implements Opus {
- private final int yearCreated;
- private final String title;
- protected BaseOpus (int yearCreated, String title){
- this.yearCreated = yearCreated;
- this.title = title;
- }
- @Override
- public int yearCreated(){
- return yearCreated;
- }
- @Override
- public String getTitle(){
- return title;
- }
- public abstract double setValue();
- public abstract double value();
- // b;
- @Override
- public String toString(){
- return "BaseOpus{" +
- "yearCreated= " + yearCreated() +
- "title= " + getTitle() +
- "}";
- }
- @Override
- public boolean equals (Object x){
- if (this == x) return false; //same
- if (this == null) return false; //null
- if ((this.getClass() != x.getClass())) return false; //class
- BaseOpus that = (BaseOpus) x; //typecast
- if (this.yearCreated() != that.yearCreated()) return false;
- if (this.getTitle() != that.getTitle()) return false;
- return true;
- }
- @Override
- public int hashCode(){
- int result = 3;
- result = 31 * result + yearCreated();
- result = 31 * result + getTitle().hashCode();
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement