Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Package containing our java app
- */
- package Minesweeper;
- import java.util.Random;
- import java.util.Scanner;
- /**
- * Minesweeper Class
- *
- * @author Chris Ward
- * @version 20/01/2011
- */
- @SuppressWarnings("unused")
- public class Minesweeper {
- // Our scanner to read input
- Scanner scan;
- // Our generator which generates the placement of the mines
- private Random gen;
- // Total number of mines
- private final int totalMines = 10;
- // Total number of columns
- private final int totalColumns = 10;
- // Total number of rows
- private final int totalRows = 10;
- // Number of blocks remaining
- private int remainingBlocks;
- // The cell for our grid
- private Minesweeper.Cell[][] grid;
- /**
- * main() Our main method which initializes Minesweeper, and starts a new
- * game.
- *
- * @param args
- */
- public static void main(String[] args) {
- Minesweeper game = new Minesweeper();
- game.go();
- }
- public void clear() {
- }
- public void go() {
- boolean game = false;
- do {
- game = false;
- startGame();
- show();
- while (!game) {
- game = guess();
- show();
- }
- } while (playAgain());
- endMessage();
- }
- /**
- * Cell Class; our class within a class.
- */
- private class Cell {
- private String content;
- private String hyphen;
- private boolean hasGuessed;
- public Cell() {
- this.hyphen = "- ";
- this.hasGuessed = false;
- this.content = "0 ";
- }
- public Cell(String hyphen, String content, boolean hasGuessed){
- this.hyphen = "- ";
- this.content = "0 ";
- this.hasGuessed = false;
- }
- }
- /**
- * Minesweeper()
- *
- * Our default constructor.
- */
- public Minesweeper() {
- this.scan = new Scanner(System.in);
- this.grid = new Minesweeper.Cell[10][10];
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 10; j++) {
- this.grid[i][j] = new Minesweeper.Cell();
- }
- }
- clear();
- this.gen = new Random();
- }
- private boolean playAgain() {
- String entry;
- do {
- playAgainMessage();
- entry = this.scan.nextLine();
- } while ((!entry.equalsIgnoreCase("yes"))
- && (!entry.equalsIgnoreCase("no")));
- return entry.equalsIgnoreCase("yes");
- }
- private boolean guess() {
- if(Minesweeper.Cell.){
- }
- return false;
- }
- private void show() {
- // TODO Auto-generated method stub
- }
- private void startGame() {
- // Let's clear our previous board before the new game starts
- clear();
- startMessage();
- buildGrid();
- for (int i = 1;; i++) {
- getClass();
- if (i > 8)
- break;
- for (int j = 1;; j++) {
- getClass();
- if (j > 8)
- break;
- // Minesweeper.Cell(this.grid[1][j], countClose(i, j) + " ");
- }
- }
- }
- private String countClose(int i, int j) {
- return null;
- }
- private void buildGrid() {
- // TODO Auto-generated method stub
- }
- /**
- * Below are our strings used for communication to the user.
- */
- private void startMessage() {
- System.out.println("Do you want to see the mines (yes/no)?");
- }
- private void endMessage() {
- System.out.println("Thank you for playing minesweeper.");
- }
- private void playAgainMessage() {
- System.out.println("Would you like to play again? (Yes/No)");
- }
- private void enterRow() {
- System.out.println("Enter row to guess (Value must be 0 through 7).");
- }
- private void enterColumn() {
- System.out
- .println("Enter column to guess (Value must be 0 through 7).");
- }
- private void confirmMine() {
- System.out
- .println("Do you think there is a mine at this square (yes/no)?");
- }
- private void hitMine() {
- int x = 12;
- int y = 11;
- System.out.println("Row " + x + ", column " + y + "is a mine.");
- }
- private void missMine() {
- int x = 1;
- int y = 2;
- System.out.println("Row " + x + ", column " + y + "is not a mine.");
- }
- private void loseGame() {
- System.out.println("Incorrect guess, end of game.");
- }
- private void winGame() {
- System.out.println("Correctly Guessed all cells. You win!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement