I have a problem with an enum. I have a class Type where I have two enums: RIGHT and LEFT.
In other class I have object of class Type, named value.
I have a loop:
if (currentLvl.verify(value)) {
totalPoint++;
}
where currentLvl.verify(value) is a method which verifies if value is correct. My problem is how I can get value from user. I want the user, before loop if, to write his value and after that if value is correct, totalPoint++. I want use a scanner but I can’t do value = scanner.nextInt();. How I can get value from the user and his value imput to variable value?
Sounds like you need to use the
valueOf()method to convert the String to the enum, something like this:Or if the user is entering the enum value then use the
values()array