public class AnimalGuess
extends java.lang.Object
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 and Description |
---|
AnimalGuess() |
Modifier and Type | Method and Description |
---|---|
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) |
public static void main(java.lang.String[] args)
args
- not used in this implementationpublic static void instruct()
public static void play(BTNode<java.lang.String> current)
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.java.lang.OutOfMemoryError
- Indicates that there is insufficient memory to add new
information to the tree.public static BTNode<java.lang.String> beginningTree()
java.lang.OutOfMemoryError
- Indicates that there is insufficient memory to create the tree.public static void learn(BTNode<java.lang.String> current)
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.java.lang.OutOfMemoryError
- Indicates that there is insufficient memory to add new
information to the tree.public static boolean query(java.lang.String prompt)