I am trying to make a method which converts certain inputs to a numbered output.

I am trying to make a method, which I call enumerate. It looks like this:

public static int enumerate(String user_input){
    int output = 0;
    if (user_input.equals("l")){
        output = 1;
    }
    else if (user_input.equals("r")){
        output = 2;
    }
    else if (user_input.equals("d")){
        output = 3;
    }
    else if (user_input.equals("a")){
        output = 4;
    }
    else if (user_input.equals("q")){
        output = 5;
    }
    return output;
}

I then tried to create a switch which looks like this:

switch(enumerate(user_input)){
    //moving left
    case 1:
        sharedData.setOffset(sharedData.getOffset() - 1);
    //moving right
    case 2:
        sharedData.setOffset(sharedData.getOffset() + 1);
    //moving all the way right
    case 3:
        sharedData.setOffset(74);
    //moving all the way left
    case 4:
        sharedData.setOffset(-73);
    //quitting
    case 5:
        running = false;

which should be changing certain variables based off of what is in user_input.
However, every time that I run this switch, it acts as if case 5 is always true, even when it should not be.
Also, if it helps, when I tried to check what would happen if I ran enumerate("l") using the debug terminal (I’m working in VsCode), it ran an error saying Cannot evaluate because of compilation error(s): The method enumerate(Thread[]) in the type Thread is not applicable for the arguments (String)., which is weird because enumerate should be taking the argument of a string.
Any help would be great, just trying to figure this out.

New contributor

Sybe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1