I have a message, for example KU7.
Also, I have a set of rules, like this:
Q K S 7 J ... U
R Y L B 8 ... W
and so on. I need to translate the message using this rules. There is ~20. Translated message will be YWB.
What I have tried:
To create a method that takes a char as and argument, method has a lot of case blocks (all rules) and returns translated char. Then using for loop I loop through the message and translate symbol by symbol.
But I think it is not good solution.
Can anybody provide me with other ideas / solutions / links to similar questions?
You can use
HashMapfor storing keys and corresponding entries.