Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add a view menu with options to use a finite or toroidal game board Instructions There will be two options for the type of universe.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Add a view menu with options to use a finite or toroidal game board Instructions There will be two options for the type of universe. Finite and Toroidal. A finite universe stops are the boundaries of the game board, while a toroidal universe wraps around at the boundaries of the universe. View Menu 1. Add a new wxMenu* for a View menu. 2. The menu items that will be placed in the View menu will need to be created differently than the other menu items because the items in the View menu will show a check mark next to the item if it is enabled. 3. Create a wxMenultern* in the main panel for the menu item for the Finite option and another for the Torodial option. 4. Create wxMenu* in the constructor for the View menu. 5. Instantiate the two new menu items. A new wxMenultern takes in several arguments. a. Parent. In this case it's the View menu b. ID c. Text to be display (Finite or Toroidal) d. A text hink. This can be an empty string. e. Style options. The option that is needed here is walTEM CHECK. 6. After each item is instantiated, it is necessary to call SelCheckable(true) on each item. 7. Create everit handlers for each new menu item and add entries to the Event Table for those event handlers. A. In the event handler, the menu option for Finite and Toroidal will need to be set by calling the Check(true] or Check false] method on the menu option. Options 1. Add an option to the Settings object to store whether the universe is Finite or Toroidal. 2. The View menu will display this as two separate entries, but it is actually only one option. The universe is either Finite or Toroidal. 3. This option will need to be changed when the event handlers for the menu items are created. Implementation 1. The universe should currently be defined as finite, meaning that the cells at the edges do not have as many neighbors are those in the center. 2. The Toroidal option will be implemented inside the logic that calculates the number of living neighbors that a cell has. When the Toroidal option is enabled and a cell on the edge is being checked, rather than skipping over certain indices, the index in question will wrap around to the other edge. a. An index of -1 will become the grid size - 1 b. An index of grid size will become 0 Wrap Up67 //Menu Bar wxMenuBark menub = new uxMenuBar(); wxMenu* options = nem wxMenu(); 71 wxMenu* file = nem wxMenu(); 72 wxMenu* universe = new uxMenu(); 73 SetMenuBar (menub) ; 75 76 options->Append(10806, "Settings"); menub->Append (options, "Options"); 78 options->AppendCheckItem(10808, "Show Neighbor Count"); 79 options->Append (10809, "Randomize"); options->Append(10810, "Randomize with seed"); menub->Append (file, "File"); 82 file->Append(10811, "New"); 83 file->Append (10812, "Open"); file->Append(10813, "Save"J; 85 file->Append (10814, "Save As"); File->Append(10815, "Exit"); menub->Append (universe, "Universe Type"J; 89 98 //Universe Type 91 Finite = new wxMenuItem(universe, 10016, "Finite", ", wxITEM_CHECH); 92 Torodial = new wxMenuItem(universe, 18017, "Torodial", "", wxITEM_CHECK); 93 94 Finite->SetCheckable (true); 95 Torodial-SetCheckable(true); 96 97 universe->AppendCheckItem(10816, "Finite"); 98 universe-AppendCheckItem(10817, "Torodial"); 99\f179 int MainWindow: : NeighborCount(int row, int col) 180 181 182 int count = 0; 183 for (int i = - 1; i = setting. gridsize) 202 203 nrow = 0; 204 205 if (ncol = setting. gridsize) 216 211 ncol = 0; 212 213 214 if (gameboard [nrow] [ncol]) 215 216 count++; 217 218 219 228 return count; 221\f

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

3 Enumerate the tests of a good market segment.

Answered: 1 week ago