0

I'm trying to restructure some of my code and realized that I need to create an abstract class to have abstract methods. However, I'm having a problem with typing and am not sure what the problem is (and, therefore, not sure what the solution is). I have the abstract superclass:

abstract public class CondInd<T> {

    abstract public double score(CondInd<T> n);;

    abstract public ArrayList<Collection<CondInd<T>>> search();;

    abstract public void increaseScore(Set<CondInd<T>> input);;
}

and I have my subclass:

public class Node<T> extends CondInd<T> {

    public double score(Node<T> nodelst){    //EDITED thanks to Martin
        return 0.0;
    }
    public ArrayList<Collection<Node<T>>> search(){   //To Implement
        return new ArrayList<Collection<Node<T>>>();
    }

The problems I'm having is the implemented methods in Node aren't overriding those in the superclass because it says the return types of the implemented methods in Node don't match those in the superclass.

It's something to do with typing but I'm not very good with generic types and abstract classes.

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
g00glechr0me
  • 365
  • 6
  • 19
  • This isn't a complete duplicate. He also has a bug. The `Node` class `score` method passes a `Collection>` but the abstract class `score` takes a single `CondInd`. – Martin Serrano Oct 07 '15 at 17:28
  • Sorry about that. The bug was because I copied another implementation of the score method. From the other threads answer, I still don't understand how to fix the typing to eliminate the errors. Any ideas? – g00glechr0me Oct 07 '15 at 17:42

0 Answers0