Results 1 to 2 of 2
Thread: Why does this program not end?
- 07-31-2007, 04:49 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
Why does this program not end?
Hi, This is my java minesweep game:
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.Java Code: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; } }
Thanks.
- 08-07-2007, 07:22 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
Similar Threads
-
Executing a program within a program
By gibsonrocker800 in forum New To JavaReplies: 5Last Post: 05-12-2008, 08:24 AM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
cannot run the program
By amiey in forum New To JavaReplies: 1Last Post: 11-20-2007, 04:13 AM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM -
I need help with this program
By Daniel in forum Advanced JavaReplies: 2Last Post: 07-04-2007, 05:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks