Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a c++ program Minesweeper This game was made popular by the Windows operating system in the early 1990s, and it has continued to be

Write a c++ program

Minesweeper

This game was made popular by the Windows operating system in the early 1990s, and it has continued to be a pre-installed game until Windows 8. You can watch a video of how to play minesweeper on YouTube or read about it on Wikipedia:

The game is very simple. The object of the game is to open/reveal every cell on the board without detonating a mine. Every cell contains a number or a mine. The numbers tell you how many mines surround the cell in the horizontal, vertical, and diagonal directions, e.g. at most, 8 possible mines surrounding a cell. You can flag a cell, which helps you remember where you think there is a mine to not detonate. If you select to open/reveal a cell that has a mine, then you automatically lose the game!

You will then randomly distribute the mines on the board and setup the numbers describing how many adjacent mines to each cell. After that, you will display a blank board, and ask the user to flag or open a cell on the board until the user selects a cell that contains a mine (losing the game) or selects all cells free of mines (winning the game). After the user wins or loses, you will ask the user if he/she wants to play again. If so, you must get the number of rows, columns, and mines for the new game and create a new board for a new game. BTW, you can display row and column numbers on board to make it easier to read/know which row and column to select!!!image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Requirements for game:

You must provide a usage message, if the user enters incorrect command-line arguments, and they can come in any order!

You must not have functions over 15-20 lines long (-10 automatically)

You must not use global variables (-10 automatically)

You must ask the user if he/she wants to play again

o If no, then end

o If yes, then prompt for rows, cols, and mines for new game.

You must not have any memory leaks (-10 automatically)

You must detect these errors:

o Invalid row or column to flag or open o Opening a cell that has already been opened

(10 pts) Extra Credit: Recursively open all cells adjacent to 0 cell

If the user selects a cell that has no mines surrounding it, then you will help the user by recursively opening all adjacent cells to empty cells, until you reach cells with a surround mine.

a.out -r 9 -c 9 -m 10 Flag (1) or Open (2)2 row, col: 0 4 You lose!!! 1211121212101010 12112121 1101010l 111131 1210101010 1113121210101010 111213121110 1010101 111*I*110 10101010I

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_2

Step: 3

blur-text-image_3

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

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

Proficiency with Microsoft Word, Excel, PowerPoint

Answered: 1 week ago