2 Replies - 1078 Views - Last Post: 18 October 2005 - 05:46 PM Rate Topic: -----

#1 Bucky2k4  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-October 05

Need help with method implementation

Posted 18 October 2005 - 05:01 PM

I'm at a total lost on how to implement these methods. If anyone can help out that be great.


/**   Adds a node to this graph.
@param node the node to add
@throws IllegalArgumentException if node already exists in the graph
@throws NullPointerException if node is null*/
void addNode(Object node){

}

/**   Adds an edge that joins two nodes.
@param fromNode the starting node for this edge
@param toNode the ending node for this edge
@param edge the edge to add
@throws IllegalArgumentException if edge already exists in the graph,
or if startNode or endNode do not exist.
@throws NullPointerException if edge is null
*/
void addEdge(Object fromNode, Object toNode, Object edge){

}

/**   Gets the start node of a given edge.
@param edge an edge of this graph
@return the start node of this edge, or null if this edge does not
exist in the graph.
*/
Object getStartNode(Object edge){

}

/**   Gets the start node of a given edge.
@param edge an edge of this graph
@return the end node of this edge, or null if this edge does not
exist in the graph.
*/
Object getEndNode(Object edge){

}

/**   Gets all nodes in this graph.
@return an immutable collection of all nodes in this graph
*/
Collection getNodes(){

}

/**   Gets all edges that start or end with the given node.
@param node a node of this graph
@return an immutable collection of all edges that start or end
with node. The collection should be empty if node is a node of this
graph
*/
Collection getEdges(Object node){

}



Is This A Good Question/Topic? 0
  • +

Replies To: Need help with method implementation

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Need help with method implementation

Posted 18 October 2005 - 05:30 PM

Normally before assisting with an assignment, we like to see the code the user has attempted first, so if you could post that, it would be great. Also, was this all that you were provided in the way of assignment instructions?
Was This Post Helpful? 0
  • +
  • -

#3 Bucky2k4  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-October 05

Re: Need help with method implementation

Posted 18 October 2005 - 05:46 PM

That's all there is for instruction. I've attempted some of the method. I thought ArrayList was a good data structure to tackle this problem, but at lost one few methods.


private ArrayList list = new ArrayList();

/**   Adds a node to this graph.
@param node the node to add
@throws IllegalArgumentException if node already exists in the graph
@throws NullPointerException if node is null*/
void addNode(Object node){
  list.add(node);

}

/**   Adds an edge that joins two nodes.
@param fromNode the starting node for this edge
@param toNode the ending node for this edge
@param edge the edge to add
@throws IllegalArgumentException if edge already exists in the graph,
or if startNode or endNode do not exist.
@throws NullPointerException if edge is null
*/
void addEdge(Object fromNode, Object toNode, Object edge){

}

/**   Gets the start node of a given edge.
@param edge an edge of this graph
@return the start node of this edge, or null if this edge does not
exist in the graph.
*/
Object getStartNode(Object edge){

}

/**   Gets the start node of a given edge.
@param edge an edge of this graph
@return the end node of this edge, or null if this edge does not
exist in the graph.
*/
Object getEndNode(Object edge){

}

/**   Gets all nodes in this graph.
@return an immutable collection of all nodes in this graph
*/
Collection getNodes(){
  for(int i=0;i<list.size();i++)
    Collection collect = list.get(i);
   return collect;

}

/**   Gets all edges that start or end with the given node.
@param node a node of this graph
@return an immutable collection of all edges that start or end
with node. The collection should be empty if node is a node of this
graph
*/
Collection getEdges(Object node){

}



This is about as much as I can figure out atm. Mixture of Collection and Object method has me completely confused. I'm not an advance programmer, so I'm not to confident in my understanding of what the is asked.

This post has been edited by Bucky2k4: 18 October 2005 - 05:46 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1