Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Minesweeper {
- public static void main (String[] args) {
- int r = 0;
- int c = 0;
- boolean lost = true;
- Scanner scan = new Scanner(System.in);
- System.out.println("Welcome to Minesweeper!\nPlease input 1 for easy, 2 for medium, 3 for hard");
- MineBoard game = new MineBoard(scan.nextInt());
- scan.nextLine();
- System.out.print(game.toString());
- System.out.println("Please enter the row, then the column.");
- r = scan.nextInt();
- c = scan.nextInt();
- scan.nextLine();
- game.fillBoard(r-1,c-1);
- game.uncover(r-1,c-1);
- while (!game.win()) {
- System.out.print(game.toString());
- System.out.println("Please enter the row, then the column.");
- r = scan.nextInt();
- c = scan.nextInt();
- scan.nextLine();
- lost = !game.uncover(r-1,c-1);
- if (lost) {
- break;
- }
- }
- if (lost) {
- System.out.println("You lost.");
- } else {
- System.out.println("You won!");
- }
- System.out.println(game.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement