Question: The Maze class should include the following methods: void Maze::readMaze(const string& fileName) Parameters: A C++ string that will not be changed by the function and
The Maze class should include the following methods: void Maze::readMaze(const string& fileName) Parameters: A C++ string that will not be changed by the function and that contains the name of an input file. Returns: Nothing. This method should read maze data from the specified input file into the maze array. First, open the input file and check for success. In the case of failure, print an error message and exit the program. Next, read the actual height and width of the maze in as integers. These integers can be used as the loop limits when reading the characters that represent the maze. Use a pair of nested for loops to read the characters that make up the rows and columns of the maze. Store each character read in the corresponding element of the two-dimensional array. When you encounter the START or END characters, save the current row and column subscripts as the ypos and xpos of the start or end of the maze. Once all of the maze data has been read, close the input file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
