import java.util.*;
/**
* RoadPoints.java
*
*
* Created: Mon Nov 29 21:50:36 2004
*
* @author Disha Al Baqui
* @author Donald W. Bassett
* @author Monica A. Ranadive
* @author Kyle R. Schmidt
* @version 1.0
*/
public class RoadPoints extends SearchNode {
/**
* index
- the index holds the ID for the roadPts,
* this is an arbitrary number given to the roadPoint by the
* programmer (this number will change with each map rcreated)
*
*/
private int index;
/**
* children
- the vector of children hold all the
* other roadPts this roadPoint can get to directly
*
*/
private Vector children;
/**
* isGoal
- holds a boolean value (set by the Map
* class) of whether or not this node is actually the goal for the
* map traversal problem. The value of this boolean is initially
* set to false, it can be changed later with the setGoal()
* method.
*
*/
private boolean isGoal = false;
/**
* Creates a new RoadPoints
instance.
*
* When the roadPoint is initialized, it initializes the index to
* a given integer and initializes the vector of children
* (children will be entered later)
*
* @param index an int
value - the index of the
* roadPoint
*/
public RoadPoints(int index){
this.index = index;
children = new Vector();
}
/**
* addChild
- this method adds a child to the
* children vector
*
* @param child a RoadPoints
value - a RoadPoint this
* is connected to
*/
public void addChild(RoadPoints child)
{
children.addElement(child);
child.parent = this;
}
/**
* setGoal
- will change the isGoal boolean from
* false to true, making it the goal for the robot
*
*/
public void setGoal()
{
isGoal = true;
}
/**
* isConnected
- this method will return whether the
* current node is a parent of another node that is specified in
* the parameters of the method
*
* @param point a RoadPoints
value - the child in question
* @return a boolean
value - returns true if the two
* road points are connected, otherwise returns false
*/
public boolean isConnected(RoadPoints point)
{
for(int i = 0; i < children.size(); i++){
if((children.elementAt(i)).equals(point))
return true;
}
return false;
}
/**
* expand
- method is used in the
* BreadthFirstSearcher to find the optimal path for the robot, it
* returns the children of the current road point
*
* @return a Vector
value - the children of the road
* point
*/
public Vector expand()
{
return children;
}
/**
* isGoal
- returns a boolean value of whether this
* point is the goal or not
*
* @return a boolean
value - returns true if this
* point is the goal, false otherwise
*/
public boolean //System.out.println(map);
}
isGoal()
{
return isGoal;
}
/**
* getIndex
- returns the index of the road point
* (this index is specified by the programmer in the Map class)
*
* @return an int
value - returns the index of the
* road point
*/
public int getIndex()
{
return index;
}
/**
* toString
- returns a string representation of the
* road point. Since the point does not have too many variables,
* it simply returns the point's index as a string.
*
* @return a String
value
*/
public String toString()
{
return new Integer(index).toString();
}
} // RoadPoints