我有一个类Vertex<T>
其实施IVertex<T>
其实施Comparable
。每当我编译我的代码,我得到的错误:非抽象类不能覆盖Comparable中的抽象方法compareTo?
Vertex is not abstract and does not override abstract method compareTo(IVertex) in Comparable
这样做的问题是,我不能在接口IVertex
内更改任何代码因为这是我的老师已指示。我该如何解决这个问题?我已经包括了我的代码如下:
顶点:
package student_solution;
import graph_entities.*;
import java.util.*;
public class Vertex<T> implements IVertex<T>{
// Add an edge to this vertex.
public void addEdge(IEdge<T> edge){
}
// We get all the edges emanating from this vertex:
public Collection< IEdge<T> > getSuccessors(){
}
// See class Label for an an explanation:
public Label<T> getLabel(){
}
public void setLabel(Label<T> label){
}
}
IVertex:
package graph_entities;
import java.util.Collection;
public interface IVertex<T> extends Comparable<IVertex<T>>
{
// Add an edge to this vertex.
public void addEdge(IEdge<T> edge);
// We get all the edges emanating from this vertex:
public Collection< IEdge<T> > getSuccessors();
// See class Label for an an explanation:
public Label<T> getLabel();
public void setLabel(Label<T> label);
}
预先感谢您!
那么,实现你忘了实现的方法(即'public int compareTo(IVertexv)'。 –
编译器告诉你你的类必须实现compareTo方法 - 就这么简单吧。 – duffymo
更多阅读错误信息它说的是顶点,而不是'IVertex'。 – EJP