7

I would like to define a class ContextItem as the extension of java class Predicate with a trait Confidence.

Confidence is a simple trait which simply adds a confidence field to whatever it extends.

trait Confidence{
  def confidence:Double
}

I am defining my ContextItem class by simply stating:

class ContextItem extends Predicate with Confidence{}

But attempting to compile this yields...

com/slug/berds/Berds.scala:11: error: overloaded method constructor Predicate with     alternatives:
  (java.lang.String,<repeated...>[java.lang.String])com.Predicate <and>
  (java.lang.String,<repeated...>[com.Symbol])com.Predicate <and>
  (java.lang.String,java.util.ArrayList[com.Symbol])com.Predicate <and>
  (com.Predicate)com.Predicate <and>
  (com.Term)com.Predicate <and>
  (java.lang.String)com.Predicate
 cannot be applied to ()
class ContextItem(pred:Predicate) extends Predicate with Confidence{
             ^

This seems like a trivial example, so what's going wrong?

Predicate (which is not mine) looks like:

/** Representation of predicate logical form. */
public class Predicate extends Term implements Serializable {
    public Predicate(String n) {
        super(n);
    }
    public Predicate(Term t) {
        super(t);
    }
    public Predicate(Predicate p) {
        super((Term)p);
    }
    public Predicate(String n, ArrayList<Symbol> a) {
        super(n, a);
    }
    public Predicate(String n, Symbol... a) {
        super(n, a);
    }
    public Predicate(String n, String... a) {
        super(n, a);
    }
    @Override
    public Predicate copy() {
        return new Predicate(this);
    }
}

Neither Predicate nor any of its ancestors implements confidence.

1
  • Could we see the Predicate class? Does it implement the confidence method? Commented Apr 17, 2013 at 20:55

1 Answer 1

6

I think it is listing all the constructors of Predicate, and informing you that you're not using any of them. The default is to use a parameterless constructor, which doesn't exist here. The syntax to call, for example, the (String) super-constructor, would be

class ContextItem extends Predicate("something") with Confidence

or

class ContextItem(str: String) extends Predicate(str) with Confidence

Also, at the moment your def confidence is an abstract method, so won't compile until you give it a definition. If you intended the trait to add a writable confidence field then this is what you want instead:

var confidence: Double = 0.0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.