I have a java program that should import and read a textfile containing lines of morse code as well as english phrases. The program should use a binary tree and hashmap to decode both the morse and the english phrases. I have built my binary tree for the morse that reads another text file (that contains the alphabet and their coordinating morse code values). How could I go about adding a hashmao to my code to read the english part of the textfile? I am stuck!
Stephan van Hulst wrote:Why have you settled on these data structure . . .
She hasn't. She has been told to use them as an exercise in using those data structures. I think, “decode,” should read, “encode.”
ER: You are asking the wrong question
How could I go about adding a hashmao to my code to read the english part of the textfile?
You don't use Maps to read text files. You use Scanners or Buffered Readers or similar. You have confused yourself because you haven't broken the task down enough. Reading the different files is two separate tasks distinct from using maps or trees.
By the way: What are you going to do when your text contains spaces? How are you going to distinguish "." (=Morse code for e) from "." (=common punctuation mark)? Do you have the Morse Code and the letters in different columns? That could distinguish them, and I would use a Scanner to read such a file.
Have you got a MorseCodeCharacter (or similar) class? I don't know whether such a class would make it easier or harder to do this exercise.
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop