Java interface problem

Hi everyone,

I am a student doing computer science degree. This term we are doing Programming Techiques in Java with Graph algorithms.

However I found the assignment question is very strange,I made it simple as below:

There are two basic interfaces :Node.java Arc.java. which each Has only one interface method compareTo();

public interface Node extends Comparable<Node>{

int compareTo(Node n);

}

And we have a Graph.java interface with some method like: getArcs[] , getNodes[] to get Arc and Node info from a graph object.

we are supposed to implement those three interface with NodeImp.java and ArcImp.java and GraphImpl.java.

What we should do is in a Assig.java class, we solve some graph problem one of which is

public static boolean isReachable(Graph g, Node source, Node destination){

// Here I cast the Node source Object into my own NodeImp class

// and make use of some other method defined in my NodeImp

// class

}

I have done and test my implementation of this method successfully but cannot pass some auto testing program provided in the University.

The reason I failed is "I shouldn't use method outside the Node or Arc interface,which means We should only use compareTo() method in the isReachable method" said by our lecturer.His reason is when someone else passed his NodeImp class in , it may not have the method what I defined in my NodeImpl.java. So I faile the test.

I do understand what my lecturer means, but if in that case we can only use compareTo() method in a Node, which can do nothing at all. Does that mean I

can only write one method in my NodeImp.java?

So any one give me some idea what should I do.

Thanks very much.

[1786 byte] By [Liupengjiana] at [2007-11-26 18:44:35]
# 1
Given a finite Graph and a source node, write a breadth-frst search from the source node. Either you encounter the destination node or you exhaust all the nodes in the Graph. I don't even see the need to compare nodes to write that.
DrLaszloJamfa at 2007-7-9 6:18:30 > top of Java-index,Java Essentials,Java Programming...