Answered step by step
Verified Expert Solution
Question
1 Approved Answer
First two pictures are the instructions, last two are the input file and output file respectively. It should be written in C++ and it should
First two pictures are the instructions, last two are the input file and output file respectively. It should be written in C++ and it should accept any input file and not just the one above. Smart pointers must be used
SimMold Rules Each cell has at most 8 neighbors (cells on the edge of the world will have fewer): 4 6 Cell 7 5 8 If a cell contains a mold spore and has fewer than 2 neighbors, the mold spore dies. O A neighbor is a mold spore in one of the 8 spots (or fewer if on the edge) around a cell If a cell contains a moldspore and has more than 3 neighbors, it dies from overcrowding. If an empty location has exactly three neighbors, a mold spore is born in that location. All births and deaths happen simultaneously. o No changes should be made to the world until all cells have been tested. Details The world in which the mold lives will be implemented as a 2 dimensional array. The array will be dynamic o The size of the array will be determined by the file containing the initial mold generation. 0 You may create a dynamic multi- or single dimension array - Dynamic multi-dimensional arrays require double pointers (which we will not cover) . This is an option for students with a more advanced skill set. o Remember that standard multi-dimensional arrays in C++ are stored as single dimension arrays in memory . This may be easier to work with than the double pointers. The initial mold generation will be read from a file. The use of pointers is required to traverse the array. You must use smart pointers to interact with the array O Bracket notation (-20 points if used) is not allowed for accessing the array Input: Prompt the user for the name of the file containing the initial generation of mold. Each line in the file will represent a row in the 2D array. The array you create is to be no bigger than the initial mold generation presented in the file. You will need to determine how many rows and columns are in the file before creating the array. Details The world in which the mold lives will be implemented as a 2 dimensional array. The array will be dynamic o The size of the array will be determined by the file containing the initial mold generation. 0 You may create a dynamic multi-or single dimension array Dynamic multi-dimensional arrays require double pointers (which we will not cover) . This is an option for students with a more advanced skill set. o Remember that standard multi-dimensional arrays in C++ are stored as single dimension arrays in memory . This may be easier to work with than the double pointers. The initial mold generation will be read from a file. The use of pointers is required to traverse the array. You must use smart pointers to interact with the array. O Bracket notation (-20 points if used) is not allowed for accessing the array Input: Prompt the user for the name of the file containing the initial generation of mold. Each line in the file will represent a row in the 2D array. The array you create is to be no bigger than the initial mold generation presented in the file. You will need to determine how many rows and columns are in the file before creating the array. Each row will contain two types of characters - an asterisk (*) or a space. An asterisk represents a mold spore and the space represents an empty cell. Each line of the file will end with a newline character, except the last line. The last line may or may not have a newline character at the end Once the file has been read into memory, prompt the user to enter the number of generations to simulate. The maximum number of generations allowed for simulation is 10. You must validate that the user only enters an integer from 1 - 10. If the user enters invalid data, display an error message and prompt the user for correct input. Output: After the user has entered a valid number, display each generation to the console. Include a header before each generation: GenerationStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started