i have a java problem.

i'm trying to write the hunt the wumpus game with simple conditions: (check-marked the ones i already accomplished)
[x]the pits will be placed randomly
[x] the wumpus is placed in the maze randomly (not sure if i did that one correctly)
[x] the player starts on the lower left of the maze row 3 col 0
-the player will only have 1 chance to shoot the Wumpus
[x]if the player is close to the Wumpus then there would be a prompt saying there is stench around
[x]if the player is close to a pit then she/he will be prompted that there is a breeze.
-if the player falls in a pit or gets eaten by the wumpus the game will be over and the map of the maze will be shown. I used 0 for empty cells and p for pits and w for wumpus in the array.

There is some problem with the program i've written so far but i don't know how to fix it. also, i don't know how to check if the wumpus will be in the direction the player wants to shoot. i'd appreciate any suggestions

Code: ( text )
-java

import java.util.*;
public class playWumpus
{
//initMaze METHOD
//put the pits and wumpus into the world
public static void initMaze(char [][] maze)
{
Random r = new Random();

for (int row = 0; row <4; row ++)
{
maze[row][col] = 'O'; <<<<<<there is a problem here
}
int pitRow, pitCol;
for (int pitNum = 0; pitNum <4; pitNum++)
{
pitRow = r.nextInt(4); //randomly choose row
pitCol = r.nextInt(6); //randomly choose column
if (pitRow == 3 && pitCol == 0)//start location
{
pitCol=5;
}
}
maze [pitRow][pitCol] = 'p'; //places the pits in the maze randomly
maze [r.nextInt(4)][r.nextInt(6)] = 'w'; //places the wumpus randomly in the maze
}// end of Maze method


//CHECKMOVE method
//possible outcomes: run into the wall , fall into the pit, eaten by wumpus,
//feel breeze, smell stench, nothing.
public static int checkMove(char [] [] maze, int newRow, int newCol)
{
//checks if they run into a wall
if (newRow<0 || newRow>3 || newCol<0 || newCol>5)
{
System.out.println("You hit a wall");
return 0;
// it will return to the main method and places 0 in the state variable
}
else if (maze[newRow][newCol] == 'p')
//this checks the maze if there is a P in that location
{
System.out.println("You fall into a pit");
return 2;
// it will return to the main method and places 2 in the state variable
}
else if (maze[newRow][newCol] == 'w')//checks for the wumstem.out.println("You've eaten by the Wumpus!!");
}
//checks for the breeze (right,left,down,up) //<<is the following if-statement correct?>>>
if (
(newCol>0 && maze[newRow][newCol-1] == 'p') ||
(newCol<5 && maze[newRow][newCol+1] =='p') ||
(newRow>0 && maze[newCol][newRow-1] == 'p') ||
(newRow<3 && maze[newCol][newRow+1] =='p')
)
{
System.out.println("You feel a breeze");
}
return 1;

}//end of the maze method

public static void main(String [ ] args)
{
char [ ] [ ] maze = new char [4][6]; //the actual map of the game
int playerRow=3, playerCol=0; // player location aka lat/long
Scanner in= new Scanner(System.in); //<<there is something wrong with my scanner>>>
int move, state;
// state of the game
// state 0= illegal move, 1= legal move, 3= end game
initMaze (maze); // calling the initMaze method
do
{
System.out.println("What would you like to do? 1=up, 2=down, 3=right 4=left, 5=shoot");
move = in.nextInt(System.in); //<<for some reason eclipse is telling me that the type is incorrect>>
if (move ==1) // move up in the world
{
state = checkMove(maze, playerRow-1,playerCol); //these are coordinates
if ( state >0 ) // legal move
{
playerRow = playerRow-1;
}
}
if (move ==2) // move down in the world
{
state = checkMove(maze, playerRow+1,playerCol);
if ( state >0 ) // legal move
{
playerRow = playerRow+1;
}
}
if (move ==3) // move right in the world
{
state = checkMove(maze, playerRow,playerCol+1);
if ( state >0 ) // legal move
{
playerCol = playerCol+1;
}
}
if (move ==4) // move left in the world
{
state = checkMove(maze, playerRow,playerCol-1);
if ( state >0 ) // legal move
{
playerRow = playerCol-1;
}
}
if (move == 5) // shoot the wumpus in the world
{
System.out.println("Which direction would you like to shoot? 1=up, 2=down, 3=right, 4=left");
int shootDir = in.nextInt(System.in);

// check if the wumpus gets killed
if ( shootDir == 1 )
{
System.out.println("You shot the Wumpus!");
}

}
}while (state!=2);
}//end of main

}//end of class

There are a few issues with your code. I'll go through them step by step and provide suggestions for fixing them:

1. Problem: In the `initMaze` method, you have an error on the line `maze[row][col] = 'O';`. There is no `col` variable defined in the loop. You can fix it by replacing `col` with `0`.

Solution: Update the line to `maze[row][0] = 'O';`.

2. Problem: In the `initMaze` method, you generate random coordinates for `pitRow` and `pitCol`, but you don't use those coordinates to place the pits and wumpus in the maze. Instead, you generate new random coordinates for the wumpus.

Solution: Update the lines where you place the pits and wumpus to use the `pitRow` and `pitCol` variables.

```java
maze[pitRow][pitCol] = 'p'; // Place the pits in the maze randomly
maze[pitRow][pitCol] = 'w'; // Place the wumpus in the maze randomly
```

3. Problem: In the `checkMove` method, the condition for checking the breeze around the player has an error. You are using `newCol` instead of `newRow` in the third condition.

Solution: Update the condition to use `newRow` instead of `newCol`.

```java
if (
(newCol > 0 && maze[newRow][newCol - 1] == 'p') ||
(newCol < 5 && maze[newRow][newCol + 1] == 'p') ||
(newRow > 0 && maze[newRow - 1][newCol] == 'p') || // Updated this line
(newRow < 3 && maze[newRow + 1][newCol] == 'p') // Updated this line
)
{
System.out.println("You feel a breeze");
}
```

4. Problem: In the `main` method, you have an error when reading the move choice from the user. The `nextInt` method doesn't need an argument.

Solution: Update the line to use `in.nextInt()` instead of `in.nextInt(System.in)`.

```java
move = in.nextInt();
```

5. Problem: In the `main` method, you have an error when reading the shoot direction from the user. You are again passing `System.in` as an argument to `nextInt`, which is not needed.

Solution: Update the line to use `in.nextInt()` instead of `in.nextInt(System.in)`.

```java
int shootDir = in.nextInt();
```

With these fixes, your code should work correctly. However, you still need to add the game over conditions when the player falls into a pit or is eaten by the wumpus. You can add an appropriate `state` value and update the `do-while` loop condition to check for that state.

There are a few issues in your code that need to be addressed.

1. In the `initMaze` method, you have a line `maze[row][col] = 'O';`, but there is no `col` variable declared. You should change it to `maze[row][0] = 'O';` to set the initial empty cells.

2. You have a logic problem in the `initMaze` method where you generate random positions for pits and the wumpus, but you don't actually assign them to the maze. You should move the lines `maze[pitRow][pitCol] = 'p';` and `maze[r.nextInt(4)][r.nextInt(6)] = 'w';` inside the loop where you generate random positions.

Here's the corrected `initMaze` method:

```java
public static void initMaze(char [][] maze) {
Random r = new Random();

for (int row = 0; row < 4; row ++) {
maze[row][0] = 'O'; // set initial empty cells
}

int pitRow, pitCol;
for (int pitNum = 0; pitNum < 4; pitNum++) {
pitRow = r.nextInt(4); // randomly choose row
pitCol = r.nextInt(6); // randomly choose column
if (pitRow == 3 && pitCol == 0) {
pitCol = 5; // avoid start location
}

maze[pitRow][pitCol] = 'p'; // place the pits in the maze randomly
}

maze[r.nextInt(4)][r.nextInt(6)] = 'w'; // place the wumpus randomly in the maze
}
```

3. In the `checkMove` method, the if-statement for checking the breeze is incorrect. The indexes in the conditions are swapped. The correct if-statement should be:

```java
if (
(newCol > 0 && maze[newRow][newCol - 1] == 'p') ||
(newCol < 5 && maze[newRow][newCol + 1] == 'p') ||
(newRow > 0 && maze[newRow - 1][newCol] == 'p') ||
(newRow < 3 && maze[newRow + 1][newCol] == 'p')
) {
System.out.println("You feel a breeze");
}
```

4. There are two issues with the `Scanner` usage. The `nextInt` method does not take any arguments, so you should remove `System.in` from `in.nextInt(System.in)`. The correct usage is `in.nextInt()`.

5. You need to initialize the `state` variable before the `do-while` loop. Add the line `int state = 1;` before the `do` statement.

6. In the logic for moving left in the `if (move == 4)` block, you have a typo where you assign `playerRow = playerCol-1;` instead of `playerCol = playerCol - 1;`. Change it to `playerCol = playerCol - 1;` to correctly update the column coordinate.

With these modifications, the code should work correctly.