Guest User

Untitled

a guest
Dec 10th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import java.awt.event.MouseAdapter;
  5. import java.awt.event.MouseEvent;
  6.  
  7. import javax.swing.JButton;
  8. import javax.swing.JOptionPane;
  9.  
  10.  
  11. public class MineSweeper {
  12.  
  13. public static boolean[][] mineField;
  14. public static boolean[][] clicked;
  15. public static JButton[][] mineButtons;
  16. public static final int MINES = 20;
  17. public static int mineCount;
  18.  
  19. public static void main(String[] args) {
  20. int r,c;
  21. mineCount = 0;
  22. mineField = new boolean[12][12];
  23. mineButtons = new JButton[10][10];
  24.  
  25. while (mineCount<MINES)
  26. {
  27. int x = (int)(Math.random()*10);
  28. int y = (int)(Math.random()*10);
  29. if (mineField[x+1][y+1] = false)
  30. {
  31. mineField[x+1][y+1] = true;
  32. mineCount++;
  33. }
  34. }
  35. new Display();
  36. }
  37.  
  38.  
  39. }
Add Comment
Please, Sign In to add comment