Hey Sorry for the what for you guys must seem like a stupid question but I've been stuck on this for a while now, im using a getter from a different class as the switch expression in another class, my program keeps skipping the entire switch alltogether.
Thank you for your time!
First class
public class InputRequests {
public int loginRole;
public void loginChoice(){
Scanner login = new Scanner(System.in);
loginRole = login.nextInt();
}
public int getLoginRole() {
return loginRole;
}
}
Second class
public class Menus {
public void loginChoiceCase() {
InputRequests inp = new InputRequests();
switch (inp.getLoginRole()) {
case 1 -> System.out.println("test");
case 2 -> System.out.println("tested");
case 3 -> System.exit(1);
}
}
}
main
public class Main {
public static void main(String[] args) {
Printblocks print = new Printblocks();
InputRequests input = new InputRequests();
Menus menu = new Menus();
print.firstMenu();
input.loginChoice();
menu.loginChoiceCase();
System.out.println(input.getLoginRole());
}
}
The first menu print is just a pintblock without anything else, when running the program I do get the int I enter back.