Main Idea:

Write a class that uses a binary tree (as shown below) to decode a string representing Morse code. This string will use “-“ to represent Dash and “.” To represent Dot. See image.

Details:

The Morse code string is kept in a file. MorseTester.java reads this text and sends it to MorseCodec.java which scans the text and sends it, one word at a time to your class, MorseDecoderTree.java. Your code will use MorseDecoderNodes to build a tree as shown above. You will write a method called convert to decode a string.

Implementation:

The class named MorseDecoderTree builds a binary tree of nodes

What you need to do:

Add bodies to the constructor MorseDecoderTree and the method convert . The constructor should build the Morse code tree by creating an overall node and a node for each symbol A-Z and 1-0, making links between the nodes as shown in the diagram above. The convert method takes a String as input and returns the plain text that corresponds to the given Morse code.

Testing:

The provided file, AlphabetInMorse.txt, contains the letters A through Z and the digits 1 through 0. The test driver, MorseTester, produces this output

Before conversion: ->.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. .---- ..--- ...-- ....- ..... -.... --... ---.. ----. ----- <-
After conversion: ->A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 <-

Main Idea:

Write a class, MorseEncoderMap.java, that uses a Map to encode a string of words into Morse code. This string will consist of the letters A through Z and theigits 1 through 0 only. The words are separated by spaces. This class does the opposite of what MorseDecoderTree does.

Implementation:

The text string is kept in a file. MorseTester.java reads this text and sends it to MorseCodec.java which scans the text and sends it, one word at a time to your class, MorseEncoderMap.java. Your code will use a Map Character, String to build a lookup table as shown below. You will write a method called convert to decode a string. See image.

What you need to do:

Add bodies to the constructor MorseEncoderMap and the method convert . The constructor should build the Map as shown in the diagram above. The convert method takes a String as input and returns the Morse code that corresponds to the given plain text.

Testing:

The provided file, AlphabetInMorse.txt, contains the letters A through Z and the digits 1 through 0. The test driver, MorseTester, produces this output

Before conversion: ->A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 <-
After conversion: ->.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. ..--- ...-- ....- ..... -.... --... ---.. ----. ----- .--- <-
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.