# Need help with method implementation

Page 1 of 1

## 2 Replies - 1170 Views - Last Post: 18 October 2005 - 05:46 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=12824&amp;s=1ea267d70cc075803fea5c6c04affb48&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Bucky2k4

Reputation: 0
• 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*/

}

/**   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

• g+ + -o drink whiskey.cpp

Reputation: 248
• Posts: 13,507
• 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?

### #3 Bucky2k4

Reputation: 0
• 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*/

}

/**   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