I've only just begun to learn Java and i'm trying to switch multiple booleans based on input. I want to do this in a method that is scaleable and a little more elegant than writing out an if statement for every possibillity. the idea is this:
int vikingcount = (input.nextInt());
while (vikingcount>0) {
V(vikingcount)=true;
vikingcount--;
}
Now I'm fully aware that the above code does not work. There are multiple booleans named V1, V2, V3 etc. and i would like the method to set the amount given by the input to true (so if the input is 3, V1 V2 and V3 would be set to true) How would I accomplish this? your help is much appreciated.