I'm fairly new to Java language and I'm having bit of problem.
I'm trying to make really simple Battle ships game. I have an array 3x3 filled with 0 and 1. 1 meaning there is a boat.
Every slot in the array is named n-n8. And I was wondering if there was a way of naming all the variables in one if statement.
The way I'm doing it right now is
if((n == 1 && x.equals("n") || (n == 1 && x.equals("n1") .. (n == 1 && x.equals("n8")){
System.out.println("Nice shot. Boat down.")}
x is user input. You probably get the point. So I would like to know if there's a way to shorten down the if statement or there's no other way. Something like :
if(n, n1, n2.. n8)
I tried looking it up but no success. Thank you in advance !