Andreas Slirig wrote:This type of code ^^, because i find it really hard do know what everything does. When i am doing an assignment i most always look back on each chapter all the time for every new thing i do ..
Well, you are kind of shooting yourself in the foot by:
1. Not documenting your work properly.
2. Not using good, descriptive names. Why, for example, are your Morse code strings called '
tab'? The only thing I get when I Google 'Morse code tab' is a bunch of music references.
3. Trying to be too "clever" when you're writing code, or trying to cram too much into each method.
For example, how about this, culled from your own
toLetter() method:
and with a
switch statement (which, since version 7, now take Strings), it would probably be even easier to follow.
Obviously, if you wanted to add tons of accented characters, you'd probably need to find another way, but it's still going to have to be a
different search from the one you use for plain letters, since there won't be any direct correlation from the index to the character.
HIH
Winston