Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create functions: Initialization print Setting up the game Teardown print Destroying the game Accept Input accept a letter for a command. The commands are the

Create functions:

  • Initialization print Setting up the game
  • Teardown print Destroying the game
  • Accept Input accept a letter for a command. The commands are the things that you can do to the board: Flag a square, unflag a square, assert that the square is bomb-free, and quit the game. Accept coordinates if appropriate. Prompt and error check appropriately.
  • Update the state of the world pass the input data to this function. Since we do not have a world right now, choosing (0,0) as bomb free will print BOOM, other moves will print OK
  • Display the state of the world Print the result calculated in the state of the world. Later, this should print the board.
  • Main call initialization, then loop until a flag is set, calling accept input, update and display. Outside of the loop, call teardown.

Make variables to define the size of the board (width and height). These can be global variables

and the output should look like

Setting up the game

(F) flag a spot as a mine, (R) remove a flag, (A) assert that a spot is mine free, (Q)uit

F

Enter your horizontal coordinate (0 - 10) and press enter

3

Enter your vertical coordinate (0 - 10) and press enter

4

OK!

(F) flag a spot as a mine, (R) remove a flag, (A) assert that a spot is mine free, (Q)uit

(F) flag a spot as a mine, (R) remove a flag, (A) assert that a spot is mine free, (Q)uit

A

Enter your horizontal coordinate (0 - 10) and press enter

0

Enter your vertical coordinate (0 - 10) and press enter

0

BOOM!

(F) flag a spot as a mine, (R) remove a flag, (A) assert that a spot is mine free, (Q)uit

(F) flag a spot as a mine, (R) remove a flag, (A) assert that a spot is mine free, (Q)uit

Q

Destroying the game

please correct those C program according to the above form thanks

#include

char letter;

int horizontal; int vertical;

void main(){

intialization(); while(flag == true){

accept_input(); update_state(); display_state();

teardown(){ printf("setting up the game: "); return 0; } intialization(){ printf("(F)flag a spot as mine,(R) remove a flag,(A)assert that a spot is mine,(Q) quit ",); }

accept_input(){ scanf("%c",&letter);

if(letter == 'F'){

scanf("%c",&horizontal); } elseif (letter= ") { return 0; } }

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

What are the four blocks in an everyday athlete program

Answered: 1 week ago

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

What are the objectives of performance appraisal ?

Answered: 1 week ago