Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generate a new (random) mine field?? for minesweeper

843785Nov 12 2008 — edited Nov 16 2008
I have to create a minesweeper game for my java class.
but im having trouble creating the method to generate a random mine field?!?!
(i dont even know where to start)
public static boolean [][] generateMineField ( int length, int width, int numberMines)
This method generates a new mine field as a matrix of boolean values where a cell is set to "true" to indicate the presence of a mine. The length and the width of the field are provided, and also the desired number of mines (numberMines).
Hint: Use Math.random(), Math.floor(), and type cast to generate random positions for the mines.

ThanK You!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 14 2008
Added on Nov 12 2008
43 comments
1,730 views