Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java language 1. Design a 2-dimensional array of booleans as a minefield for minesweeper game; true indicates that the mine is present. boolean [ ][

Java language

1. Design a 2-dimensional array of booleans as a minefield for minesweeper game; true indicates that the mine is present. boolean [ ][ ] minefield = new boolean [10] [10]; then we need to calculate the number of neighboring squares that contains mines for each square int [ ] [ ] minedNeighbors = new int [10] [10];

2. Create a unit test to develop the following code using TDD: - a constructor method that takes three parameters: number of rows, number of columns, and maximum number of mines, it also initializes the arrays. Write an existence test for this method. - a mineTile method with two parameters: rows and columns coordinate that sets the tiles to be mined and increment the neighboring mine totals of the surrounding tiles using for loops which return true if the square was successfully mined and false if it exceeded the maximum number of mines or the square is already mined. Write a test for this method as well. - a populate method to randomly scatter the mines across the minefield (exclude(0,0) tile) by calling the mineTile method. Write a populate test to check the correct number of mines are generated. create toString method to return the minefield represented by a string using " * " as a mine, and include the number of neighboring mines for unmined tiles, e.g: 00011212*1 1*11*22210 create a test for this method against minefields of differing mine numbers.

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions