biTree
Class Symbol

java.lang.Object
  |
  +--biTree.Symbol
All Implemented Interfaces:
java.lang.Comparable, WeightCompare

public class Symbol
extends java.lang.Object
implements java.lang.Comparable, WeightCompare

The leaf node class for our binary tree

Author:
Chad Cook

Field Summary
(package private)  int _value
           
(package private)  java.lang.Integer _weight
           
 
Constructor Summary
Symbol(int value)
          Constructor.
Symbol(int value, int weight)
          Constructor.
 
Method Summary
 int compareTo(java.lang.Object wc)
          The required compareTo method from Comparable.
 void execute(Visitor v)
          The hook for my visitors
 int getValue()
          Getter for the value
 java.lang.Integer getWeight()
          Getter for the weight
 void incWeight()
          Increments the weight by one
 void setWeight(int newWeight)
          Sets the weight
 java.lang.String toString()
          A toString method for testing purposes
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

_value

int _value

_weight

java.lang.Integer _weight
Constructor Detail

Symbol

public Symbol(int value)
Constructor. Automatically sets weight to one.
Parameters:
int - The value for the new symbol.

Symbol

public Symbol(int value,
              int weight)
Constructor.
Parameters:
int - The value for the new symbol.
int - The weight for the new symbol.
Method Detail

getValue

public int getValue()
Getter for the value
Returns:
The value

getWeight

public java.lang.Integer getWeight()
Getter for the weight
Specified by:
getWeight in interface WeightCompare
Returns:
The weight

incWeight

public void incWeight()
Increments the weight by one

setWeight

public void setWeight(int newWeight)
Sets the weight
Parameters:
int - The new weight

compareTo

public int compareTo(java.lang.Object wc)
The required compareTo method from Comparable. Compares the two weights, which are Integers.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
Object - What to compare this BiTree to. Must be of type WeightCompare.
Returns:
The result of comparing the weights.

toString

public java.lang.String toString()
A toString method for testing purposes
Overrides:
toString in class java.lang.Object
Returns:
"(value, weight)"

execute

public void execute(Visitor v)
The hook for my visitors
Specified by:
execute in interface WeightCompare
Parameters:
Visitor - The visitor