Topic: 请教一个编程问题,谢谢!!(interface)

  Print this page

1.请教一个编程问题,谢谢!!(interface) Copy to clipboard
Posted by: kkandcc
Posted on: 2005-12-28 02:34

题目是要写一个带权有向图的程序.如下
public class Graph {
public Graph(int maxVertices) { … }
public int getNumVertices() { … }
public MyVertex[] getVertices() { … }
public int insertVertex(MyVertex v)
public int getEdge(int inVertex, int outVertex)
public boolean setEdge(int inVertex, int outVertex, int weight)
public boolean insertEdgeDirected(int inVertex, int outVertex, int weight)...

可是题目一开始还要求用一个interface
public interface MyVertex {
public String toString();
}

我一开始是用一个一维数组来存vertex (protected int[] Vertexs;)
用一个2维数组来存edge (protected int[][] Edges;)

但我仔细看了一下题目发现这样定义不对
是不是 应该这样定义:
public class Vertex implements MyVertex{..}
public class edge{..}

谢谢!!

2.Re:请教一个编程问题,谢谢!!(interface) [Re: kkandcc] Copy to clipboard
Posted by: why
Posted on: 2005-12-28 04:17

敝人不是出題目的那位,只能說:大概是吧
為甚麼不直接問出題人呢?


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923