Please send questions to
st10@humboldt.edu .
/**
* Cs132SimpleVertex - a concrete implementation of Cs132Vertex, suitable
* for use within a Cs132Graph
*
* @author Sharon Tuttle
* @version 4-30-03
*/
public class Cs132SimpleVertex implements Cs132Vertex
{
/*----------------------------------------------------------------
fields
------------------------------------------------------------------*/
Comparable key;
Object value;
boolean visitedFlag;
/*----------------------------------------------------------------
constructors
-----------------------------------------------------------------*/
public Cs132SimpleVertex(Comparable k, Object val)
{
this.key = k;
this.value = val;
this.visitedFlag = false;
}
/*----------------------------------------------------------------
accessors
------------------------------------------------------------------*/
/*-----------------------------------------------------------------
getKey()
Purpose: returns the value of the key for this vertex
--------------------------------------------------------------------*/
public Comparable getKey()
{
return this.key;
}
public Object getValue()
{
return this.value;
}
public boolean getVisited()
{
return this.visitedFlag;
}
/*-----------------------------------------------------------------
modifiers
(note this assumption: a node's key should NOT be changed once
it is initially set... thus, there is no method setKey()
------------------------------------------------------------------*/
public void setValue(Object newVal)
{
this.value = newVal;
}
public void setVisited(boolean newFlagVal)
{
this.visitedFlag = newFlagVal;
}
/*------------------------------------------------------------
overridden methods
---------------------------------------------------------------*/
public String toString()
{
return "Cs132SimpleVertex[key: " + this.key +
"\nvalue: " + this.value +
"\nvisitedFlag: " + this.visitedFlag + "]\n";
}
/*--------------------------------------------------------------
other methods
----------------------------------------------------------------*/
}