Class AnimalGuess

java.lang.Object
  extended by AnimalGuess

public class AnimalGuess
extends java.lang.Object

The AnimalGuess Java application illustrates the use of the binary tree node class is a small animal-guessing game.

Java Source Code for this class:
http://www.cs.colorado.edu/~main/applications/Animals.java


Constructor Summary
AnimalGuess()
           
 
Method Summary
static BTNode<java.lang.String> beginningTree()
          Construct a small taxonomy tree with four animals.
static void instruct()
          Print instructions for the animal-guessing game.
static void learn(BTNode<java.lang.String> current)
          Elicits information from the user to improve a binary taxonomy tree.
static void main(java.lang.String[] args)
          The main method prints instructions and repeatedly plays the animal-guessing game.
static void play(BTNode<java.lang.String> current)
          Play one round of the animal guessing game.
static boolean query(java.lang.String prompt)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimalGuess

public AnimalGuess()
Method Detail

main

public static void main(java.lang.String[] args)
The main method prints instructions and repeatedly plays the animal-guessing game. As the game is played, the taxonomy tree grows by learning new animals. The String argument (args) is not used in this implementation.


instruct

public static void instruct()
Print instructions for the animal-guessing game.


play

public static void play(BTNode<java.lang.String> current)
Play one round of the animal guessing game.

Parameters:
current - a reference to the root node of a binary taxonomy tree that will be used to play the game.
Postcondition:
The method has played one round of the game, and possibly added new information about a new animal.
Throws:
java.lang.OutOfMemoryError - Indicates that there is insufficient memory to add new information to the tree.

beginningTree

public static BTNode<java.lang.String> beginningTree()
Construct a small taxonomy tree with four animals.

Parameters:
- - none
Returns:
a reference to the root of a taxonomy tree with the animals: kangaroo, mouse, trout, robin.
Throws:
java.lang.OutOfMemoryError - Indicates that there is insufficient memory to create the tree.

learn

public static void learn(BTNode<java.lang.String> current)
Elicits information from the user to improve a binary taxonomy tree.

Parameters:
current - a reference to a leaf node of a binary taxonomy tree
Precondition:
current is a reference to a leaf in a binary taxonomy tree
Postcondition:
Information has been elicited from the user, and the tree has been improved.
Throws:
java.lang.OutOfMemoryError - Indicates that there is insufficient memory to add new information to the tree.

query

public static boolean query(java.lang.String prompt)