Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ use vectors, that can more easily revise the ToggleGrid class to allow different dimensions and implement the Rullo game (https://www.coolmath-games.com/0-rullo ) More information

Using C++ use vectors, that can more easily revise the ToggleGrid class to allow different dimensions and implement the Rullo game

(https://www.coolmath-games.com/0-rullo )

More information below:image text in transcribed

image text in transcribed

First, the revisions you need to make:

1.)The ToggleInt class

Because of how you will probably insert values into the ToggleGrid class, you will probably want to add a constructor that takes the value (m_int in the sample solution) as a parameter.

2.)The ToggleGrid class

ROWS and COLS (or whatever you called them) are no longer constants. Remove the const, make them fields of ToggleGrid if you have not already done so, and rename them using lowercase. One best practice that really does carry over from college to work is that constants get named with all-uppercase while regular variables mostly use lowercase. The main possible exception is the first letter of a word within the name (as in sameRank).

The grid of values should now be a vector of vectors of ToggleInts: vector>. If you find it more convenient, you are free to make this a pointer to a vector of vectors of ToggleInts, but you must use ToggleInts as the type of the elements.

The constructor should still take a list of values, but it should also take int parameters for the dimensions of the gird, number of rows firsts, then number of columns. Remember that when inserting values, you have to insert a ToggleInt, not just an int (the constructor suggested above should help)

3.)The Rullo class (in rullo.h)This is the class that implements the game. The game does not have to absolutely follow the version on the coolmath site, and there is additional tracking of overall performance there, but the program must:

Support letting the user choose different dimensions for the game and have a range of valid values.

Support solutions that have squares that are toggled off

Correctly detect when the player has found the solution

Give guidance on whether the player is correct for a given row or column. You can simply list which rows and columns are correct, or you can list the sums for the current state of the players grid vs. the sums for the solution, or perhaps some other approach.

It is ok to have the user input the values and indicate either the sums for the rows/columns or which values are toggled on/off for the solution, but you may find it more interesting to randomly generate the values.

You must also use the ToggleGrid to store the values and manage the user interactions (specifically, toggling). Rewriting everything to use arrays of ints (even if you separately declare a vector) will not receive any credit for this section.

You must define a constructor that takes the dimensions of the board and the minimum and maximum for a value on the board.

There also must be a void function called play() which does not take any parameters. This will play one puzzle.

Include instructions on how to play

Allow the user to quit in the middle

4.)The driver (Driver.cpp)

In your main, describe what the program does

Using a local variable of type Rullo, play the game by calling its play() method

If you like you can put this call inside a loop that asks the player after each game whether they have had enough or want to play another game.

Therefore, you should have the following:

ToggleInt.h (Header file)

Driver.cpp

ToggleGrid.h (Header file)

Rullo.h (Header file) (must also use ToggleGrid)

constructor and the field declarations

instructions

accurate display of status of grid for what the player has toggled off or on

giving information on whether the player is currently correct for each row and for each column

correctly stopping if the player has won

allowing the player to quit in the middle

Comments for each file/class, something for each method/function, other comments to explain parts of the code when it's not clear

Choosing appropriate names for variables, functions, constants, and classes counts

Hw4 Due: February 5, end of day (extended from the syllabus) Now that we have vectors, we can more easily revise the ToggleGrid class to allow different dimensions and implement the Rullo game Chttps://www.coolmath-games.com 0-rullo). First, the revisions you need to make: The ToggleInt class a. Because of how you will probably insert values into the ToggleGrid class, you will probably want to add a constructor that takes the value" (m int in the sample solution) as a parameter. a. ROWS and COLS or whatever you called them) are no longer constants. Remove the "const". make them fields of ToggleGrid if you have not already done so, and rename them using lowercase. One "best 2. The ToggleGrid class practice that really does carry over from college to work is that constants get named with all-uppercase while regular variables mostly use lowercase. The main possible exception is the first letter of a word b. The grid of values should now be a vector of vectors of ToggleInt's: vector>. Ifyou find it more convenient, you are free to make this a pointer to a vector of vectors of ToggleInt's, but you c. The constructor should still take a list of values, but it should also take int parameters for the dimensions of the gird, number of rows firsts, then number of columns. Remember that when inserting values, you within the name (as in sameRank) must use Togglelnt's as the type of the elements. have to insert a ToggleInt, not just an int (the constructor suggested above should help) 3 The Rullo class (in crulloh") a. This is the class that implements the game. The game does not have to absolutely follow the version on the coolmath site, and there is additional tracking of overall performance there, but the program must: i. Support letting the user choose different dimensions for the game and have a range of valid values. ii. Support solutions that have squares that are toggled off ili Correctly detect when the player has found the solution iv. Give guidance on whether the player is correct for a given row or column You can simply list which rows and columns are correct, or you can list the sums for the current state of the player's grid vs. the sums for the solution, or perhaps some other approach. b. It is ok to have the user input the values and indicate either the sums for the rows columns or which values are toggled on/ off for the solution, but you may find it more interesting to randomly generate the values. c. You must also use the ToggleGrid to store the values and manage the user interactions (specifically, toggling). Rewriting everything to use array's of int's (even if you separately declare a vector) will not receive any credit for this section. d You must define a constructor that takes the dimensions of the board and the minimum and maximum for a value on the board e. There also must be a void function called play0 which does not take any parameters. This will play one puzzle. i. Include instructions on how to play ii. Allow the user to quit in the middle 4. The driver (hw4diver.cpp) is a bit more simple than the previous drivers. n your main, describe what the program does b. Using a local variable of type Rullo, play the game by calling its playO method c. Ifyou like you can put this call inside a loop that asks the player after each game whether they have had enough or want to play another game. Grading- Toggle|nt 5% hw4driver 590 ToggleGrid 20% Rullo 50% (must use ToggleGrid to do the work for credit) 10% constructor and the field declarations 10% instructions o 5% accurate display of status of grid for what the player has toggled off or on 10% giving information on ether the player is currently correct for each row and for each column 10% correctly stopping if the player has won 5% allowing the player to quit in the middle Comments count for 1096: something for each file class, something for each method function, other c Choosing appropriate names for variables, functions, constants, classes counts for 10% s to explain parts of the code when it's not clear

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

=+1. What is the brand's character or personality?

Answered: 1 week ago

Question

=+3. Who is the audience?

Answered: 1 week ago

Question

=+4. What do they (audience members) currently think?

Answered: 1 week ago