Class BucketsNode

java.lang.Object
  |
  +--SearchNode
        |
        +--BucketsNode
All Implemented Interfaces:
java.lang.Cloneable

public class BucketsNode
extends SearchNode

BucketsNode.java - Search node for buckets puzzle. Problem: Given a 5 unit and a 3 unit bucket, how can one measure precisely 4 units? Possible operations: fill/empty 1st/2nd bucket or pour contents of one to the other until source empty or recipient is full.


Field Summary
 int bucket1
          variable bucket1 - amount in first bucket
 int bucket2
          variable bucket2 - amount in second bucket
 int MAX_AMOUNT1
          variable MAX_AMOUNT1 - max amount in first bucket
 int MAX_AMOUNT2
          variable MAX_AMOUNT2 - max amount in second bucket
 
Fields inherited from class SearchNode
depth, parent
 
Constructor Summary
BucketsNode()
          Creates a BucketsNode instance and sets it to an initial search state.
 
Method Summary
 boolean equals(java.lang.Object o)
          equals - whether or not two BucketsNode objects have the same state.
 java.util.Vector expand()
          expand - return a Vector of this node's children.
 boolean isGoal()
          isGoal - test whether or not the current node is a goal node.
 java.lang.String toString()
          toString - string representation of state
 
Methods inherited from class SearchNode
childClone, clone
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bucket1

public int bucket1
variable bucket1 - amount in first bucket

bucket2

public int bucket2
variable bucket2 - amount in second bucket

MAX_AMOUNT1

public final int MAX_AMOUNT1
variable MAX_AMOUNT1 - max amount in first bucket

MAX_AMOUNT2

public final int MAX_AMOUNT2
variable MAX_AMOUNT2 - max amount in second bucket
Constructor Detail

BucketsNode

public BucketsNode()
Creates a BucketsNode instance and sets it to an initial search state.
Method Detail

isGoal

public boolean isGoal()
isGoal - test whether or not the current node is a goal node.
Overrides:
isGoal in class SearchNode
Returns:
a boolean value

expand

public java.util.Vector expand()
expand - return a Vector of this node's children.
Overrides:
expand in class SearchNode
Returns:
a Vector of SearchNodes

equals

public boolean equals(java.lang.Object o)
equals - whether or not two BucketsNode objects have the same state.
Overrides:
equals in class java.lang.Object
Parameters:
o - an Object value - object to test for equality with this
Returns:
a boolean value - whether or not two objects are equal

toString

public java.lang.String toString()
toString - string representation of state
Overrides:
toString in class java.lang.Object
Returns:
a String value