CIS2168 - Homework 9: CODING/DECONDING USING MORSE CODE
Thank you Professors Koffman and Wolfgang

Assignment given: November 2, 2010
Due Date: November 8, by 10pm

We are doing project 9 from page 358 of the textbook.
The Morse code is no longer used as extensively as in the past when telegraphs were high tech. But, counting on its return to fashion, we are going to write an application.

Letters [capital and lower case have the same encoding] are represented by dots and dashes. The encoding is described by a binary tree. The root has the label '*'. All other nodes are labeled by the distinct letters. The encoding for the letter at a node is defined by the path to this node from the root: when we go left we have a dot, when right a dash.

The Morse tree is stored in a file morse.txt that I give you. It specifies the tree in preorder traversal. You are to retrieve this tree to build your Morse tree from it. Because of our TA's worries, here is code that shows how that can be done.

You are to write two methods:
	public static  text2morse(String textFilename, String codeFilename);
	public static  morse2text(String codeFilename, String textFilename);
which, respectively, given the name of a file with text, creates a file with the corresponding Morse code, and viceversa. Any character in the input file which is not a letter, is treated as a white space
In the Morse encoding letters will be separated by single spaces and words by double spaces. You can choose the length of the lines in the Morse encoding.
As an example, this text file is converted to this file. Then the second file is converted to a file like the first but with only lowercase letters and white spaces.

Your program is to load the Morse tree and then allow the user to exercise the encoding and decoding methods.

As you know, the Morse codes for 'a' to 'z' are:
    private static final String[] MORSE_CODES = {
        ".-",   "-...", ".-.-", "-..",  ".",    "..-.",
        "--.",  "....", "..",   ".---", "-.-",  ".-..",
        "--",   "-.",   "---",  ".--.", "--.-", ".-.",
        "...",  "-",    "..-",  "...-", ".--",  "-..-",
        "-.--", "--.." };