vendredi 13 avril 2018

How would I use the result of a variable as a variable rather than plain text

The problem I have is "slowRotor" returns the value "Rotor_I".

I would like to use the result of slowRotor (Rotor_I) as the variable Rotor_I and not the "plain text" so to speak.

I'm wondering if that is possible in Java and if so, how it would be done (As i'm trying to avoid lots of if statements)

Thankyou very much

    String slowRotor = GUI.getRotorInPosition("slow");
    int position = (alphabet.indexOf(result));
    String resultAfterRotor = "";
    if (Rotor == "Slow") {          
        resultAfterRotor = Character.toString((slowRotor.charAt(position))); 
    }

And

static String alphabet ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static String Rotor_I = "EKMFLGDQVZNTOWYHXUSPAIBRCJ";   

Aucun commentaire:

Enregistrer un commentaire