Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java program Objective: Create a simple game of mine sweeper with the following classes and a driver Download the driver Put the driver in

in java program

Objective:

Create a simple game of mine sweeper with the following classes and a driver

Download the driver

Put the driver in your project

DO NOT ALTER THE DRIVER!

Write a class file called MineSpace

Attributes of this class

Selected determines whether or not this space has been clicked on

IsAMine this is whether or not it is a mine

SurroundingMines The number of mines surrounding that space

Create a default constructor with the following

Selected is set to false

IsAMine is randomly set to either true or false

Create Accessors and Mutators for each instance variable

MAKE SURE TO CHECK FOR VALID VALUES

Write another class SimpleMineSweeperBackEnd

Attributes of this class are

Spaces a 2D array of type mine space

SPACE_AMT a constant value set to 5 as this is a 5x5 minefield

numNotMinesLeft the number of mines left on the board

gameOver whether or not the game is over

win whether or not the player wins

Create a default constructor

Declare the 2D array

Call reset spaces

Create the following Methods

resetSpaces this method returns nothing and takes no parameters constructs each individual space and counts the number of not mines. It also sets each mine surroundingMines value by looking at each of its neighbors (HINT: looking setting the number of mines value maybe best done in a private method). Also it sets both gameOver and win to false.

getNumNotMinesLeft returns how many spaces that arent mines remain

getGameOver returns whether or not the game is over

getWin returns whether or not the player has won

printMines prints each mine space in the 2D array. It should print whether or not it is a mine and the number of surrounding mines. This is really good for debugging.

selectSpace this method which returns an instance of Space takes in two integers corresponding to the button that was selected. Much like other projects the x increase left to right and the y increases from top to bottom. This method should check if it is already select. If it hasnt been then set selected to true. Next check if that space is a mine. If it is then set gameOver to true and win to false. If not then subtract the number of not mines left. Next check if the number of not mines is 0 then game over should be set to true and win should be set to true.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions