Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the program solution in C++'s Visual Studio Code system that will help me get the results required in this programming assignment? *Note that

What is the program solution in C++'s "Visual Studio Code" system that will help me get the results required in this programming assignment?

*Note that the commands have to be ./lightsout and ./lightsout 0.

They cannot be just lightsout and 0 by themselves.

image text in transcribed

Lights Out Game Create an interactive program that uses the Lightsout class to play a game. First, if no command line parameter is given generate a random number. If you #include , then the following code will generate a large random number. random_device roll; int number = roll(); Use the provided parameter or the randomly generated number to initialize the game board. Recall numbers are really just a series of bits. The lowest bit (the one's column) determines the top-left (1,1) light. The next lowest bit represents the light to the right (1,2) and so on, wrapping to the next row, and ending in the bottom-right (5,5) with the 25th bit. The lowest bit of the number determines whether the number is even or odd. If the number is odd, turn the light on if it is even, do not turn the light on. Once you have "used up" that bit you can use the following code to "throw it away" and shift all the other bits "down one" so you can do it again. number >>= 1; Each turn, the state of the game must be displayed using ##'s and spaces in a grid. Use nested loops and get() to do this. Then, prompt the user for input and read input for the row and column numbers as shown below. $ ./lightsout 1 2 3 4 5 1 ## #### 2 #### 3 4 ## ## ## 5 RC: 33 1 2 3 4 5 1 ## 2 ###### 3 ## ## 4 ## ## 5 RC: If (0,0) is entered, exit the program. Otherwise, use toggle() to update the state of the game. Repeat. If all the lights are "out", instead of printing an empty grid, display the message "Congratulations!" and end the program. For example: $ ./lightsout @ Congratulations! Your source file (.cpp) should #include "lightsout.h". Lights Out Game Create an interactive program that uses the Lightsout class to play a game. First, if no command line parameter is given generate a random number. If you #include , then the following code will generate a large random number. random_device roll; int number = roll(); Use the provided parameter or the randomly generated number to initialize the game board. Recall numbers are really just a series of bits. The lowest bit (the one's column) determines the top-left (1,1) light. The next lowest bit represents the light to the right (1,2) and so on, wrapping to the next row, and ending in the bottom-right (5,5) with the 25th bit. The lowest bit of the number determines whether the number is even or odd. If the number is odd, turn the light on if it is even, do not turn the light on. Once you have "used up" that bit you can use the following code to "throw it away" and shift all the other bits "down one" so you can do it again. number >>= 1; Each turn, the state of the game must be displayed using ##'s and spaces in a grid. Use nested loops and get() to do this. Then, prompt the user for input and read input for the row and column numbers as shown below. $ ./lightsout 1 2 3 4 5 1 ## #### 2 #### 3 4 ## ## ## 5 RC: 33 1 2 3 4 5 1 ## 2 ###### 3 ## ## 4 ## ## 5 RC: If (0,0) is entered, exit the program. Otherwise, use toggle() to update the state of the game. Repeat. If all the lights are "out", instead of printing an empty grid, display the message "Congratulations!" and end the program. For example: $ ./lightsout @ Congratulations! Your source file (.cpp) should #include "lightsout.h

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

Strengthen your personal presence.

Answered: 1 week ago

Question

Know the three main dimensions of the service environment.

Answered: 1 week ago

Question

Understand the roles of signs, symbols, and artifacts.

Answered: 1 week ago

Question

Discuss the key ambient conditions and their effects on customers.

Answered: 1 week ago