I am getting a "Dead Code" warning on my battleship game. I am testing if a ship can be placed and am seeing different direction that the ship will face if it can be placed.
I then get input using In.class and after checking if it can be placed with a boolean (set to true/false when checking directions for placement) I use a 2D array of ints and set all of the locations to 1 (Starting location then + length (given as a parameter) in direction specified)
my .java file is here ShipProperties.java
if possible please keep answers to a beginners skill level (basic i/o and arrays, im pretty good with logic)
EDIT
I got it fixed and it now works as intended!
Just put the return in a if/else inside the loop
for(int i = length; i > 0; i--)
{
grid[startLocX][startLocY + i] = 1;
if(i == 0)
{
return grid;
}
}