Morse Code Lab

Goal

The goal of this project is to write a Java program to convert Morse Code to English using a Binary Tree.

Overview

The binary tree below can be used to decode Morse code.  Each left child represents a "dot" in the code, and each right child represents a "dash."  Thus the sequence "..-" (dot dot dash) decodes to the letter U.  


                                   (root)               
                                     |                   
                         -------------------------       
                       /                            \       
                     /                                \    
                   /                                    \    
                 E                                       T         
                 |                                       |        
             ---------                               --------      
          /             \                         /           \    
        /                 \                     /               \      
       I                   A                   N                 M  
   /       \           /      \            /       \           /   \
  S         U         R        W          D         K         G     O
 / \       /         /        / \        / \       / \       / \   
H   V     F         L         P   J     B   X     C   Y     Z   Q


You are to write a Java class that encapsulates the tree structure above and provides operations for converting from Morse Code.

Decoding

The morse code text is sequences of dots (periods), and dashes, separated by blank spaces.  At least one blank character must separate each "letter" (1 to 4 symbols).  Extraneous blanks (i.e., more than one) between "letters" are echoed to the output. Blanks at the beginning or at the end are ignored. Any non-alphabetic characters are ignored. 
    English text is output in upper case. 

Software Design

Use this classes (modified from Weiss's original):  BinaryNode.java  
Implement a class named CodeTree, that encapsulates the tree shown above. It provides a static method for decoding morse code:
    /**  Convert a morse code message to plain english text.
        * @param morseText a string of morse code symbols
        * @pre morseText contains valid morse code symbols.
        * @return String of the decoded english text.
    */
    public static String decode(String morseText)

Sample Test

  assertEquals("LIONS TIGERS",CodeTree.decode(".-.. .. --- -. ...  - .. --. . .-. ..."));

Implementation Constraints

Your solution for decoding morse code must be implemented using a tree structure as shown above.  That is, each morse code "letter" must be decoded by looking up its english equivalent in a binary tree like the one shown. You should build the binary tree in a static initializer block.  You must use the lookup algorithm presented in lecture.
You do not need to write a driver class.

Testing

Write JUnit tests for the CodeTree class.  You do not need to test Weiss's BinaryNode and BinaryTree.

Tip

Since the only method in the CodeTree class is a static method, don't expect that someone using your class will invoke the constructor.

For example, when you use Math.Random(), you don't create a new Math() beforehand.
So when someone uses CodeTree.encode(), they won't create a new CodeTree() beforehand.
To be safe, don't even write a constructor.

Q: OK, then how do I initialize the binary tree?
A: Probably the best way is with a static initializer block.

If you haven't done this before, you can read about it in the textbook or here.