Hi, This is my java minesweep game:
import java.io.*;
public class MineSweep1
{
static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
static private Bomb[] bmbArry = new Bomb[3];
static private char matrix[][];
public static void main(String[] args) throws IOException
{
char x,y;
matrix = new char[5][5];
for(int z = 0; z < 3; z++)
bmbArry[z] = new Bomb();
boolean explode;
explode = false;
for(x=0;x<5;x++)
for(y=0;y<5;y++)
matrix[x][y] = '*';
System.out.println("");
while (! (explode))
{
for(x=0;x<5;x++)
{
for(y=0;y<5;y++)
System.out.print(matrix[x][y]+" ");
System.out.println("");
}
explode = GetUserInput();
}
}
static boolean GetUserInput() throws IOException
{
int userX, userY;
System.out.println("Please enter an X position");
userX = Integer.parseInt(input.readLine());
System.out.println("Please enter an Y position");
userY = Integer.parseInt(input.readLine());
return IsItABomb(userX, userY);
}
static boolean IsItABomb(int X, int Y) throws IOException
{
for(int x=0;x<bmbArry.length;x++)
{
if((bmbArry[x].GetXpos() == X) && (bmbArry[x].GetYpos() == Y))
return GetUserInput();
}
return false;
}
}
when i run it and i hit a bomb, it is supposed to say "press any key to continue...." but it doesn't say that ever.
Thanks.