7
私は、クラスContextItem
を、属性Confidence
のJavaクラスPredicate
の拡張として定義したいと思います。Scala Traitを使ってJavaクラスを拡張する
信頼性は、それがどのようなものにも信頼区間を追加する単純な特性です。
私は単に述べることによって、私のContextItem
クラスを定義しています
trait Confidence{
def confidence:Double
}
:
class ContextItem extends Predicate with Confidence{}
しかし、この利回りをコンパイルしようとする...
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{
^
これは簡単な例のように思えるので、何が起こっています違う?
/** 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);
}
}
述語もその祖先のいずれかのどちらが自信を実装していますように(私のものではありません)
述語が見えます。
は、我々は 'Predicate'クラスを参照してくださいでした:あなたが書き込み可能
confidence
フィールドを追加する形質を意図した場合、これはあなたの代わりに何をしたいのですか? 'confidence'メソッドを実装していますか? – Nick