I have a string array containing strings of 3 letters each. Every 3 letters (every element) corresponds to a unique letter. I need to create a char array from the string array.<
You could use an Enum to define your elements and the corresponding character. Then have a method that decrypts the value.
Example:
public enum EncryptedValue {
A ("A", "EDK"),
B ("B", "CHI"),
C ("C", "WAD"),
...;
private String value;
private String encryption;
private static final List VALUES = Collections.unmodifiableList(Arrays.asList(values()));
private EncryptedValue(String value, String encryption) {
this.value = value;
this.encryption = encryption;
}
public String getValue() {
return value;
}
public String getEncryption() {
return encryption;
}
public String decrypt(Strign encryption) {
for (EncryptedValue encryptedValue : VALUES) {
if (encryptedValue.getEncryption().equalsIgnoreCase(encyrption))
return encryptedValue.getValue();
}
return null;
}
}