I have this method but it returns the error MyComparator is not abstract and does not overs the abstract method I have also tried using just Present instead of PresentInterface as I have already implemented the present interface in the present class. I eventually want to sort an arrayList of Presents Any help would be much appreciated thank you
public class MyComparator implements Comparable<PresentInterface>{
// The name of the present, e.g. "one directions greatest hits"
private String name;
// The type of the present, e.g. music, sweets, dvds, games.
private String type;
//The cost of the present, e.g. £11.99
private double cost;
/**
* Sets the name of the present.
*
* @param - name - the name of the present.
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the type of the present.
*
* @param - type - the type of the present.
*/
public void setType(String type) {
this.type = type;
}
/**
* Sets the cost of the present.
*
* @param - cost - the cost of the present.
*/
public void setCost(double cost) {
this.cost = cost;
}
/**
* Gets the name of the present.
*
* @return - the name of the present.
*/
public String getName() {
return name;
}
/**
* Gets the type of the present.
*
* @return - the type of the present.
*/
public String getType() {
return type;
}
/**
* Gets the cost of the present.
*
* @return - the cost of the present.
*/
public double getCost() {
return cost;
}
/**
* Converts the fields in this present object to a nicer string representation.
*
* @return - the present information in the form of a string: name - type - cost.
*/
public String toString() {
return name + " - " + type + " - " + cost;
}
@Override
public double compare( Present a){
return this.cost.compareTo(a.getCost());
}