Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please help with coding this class using C++. If possible show using separate files(.cpp .hpp) The Maze Class C) Maze o rooms: Roomtt rows: int

Please help with coding this class using C++. If possible show using separate files(.cpp .hpp)

image text in transcribedimage text in transcribed

The Maze Class C) Maze o rooms: Roomtt rows: int cols: int maze File: std:ifstream LoadMaze): void CreatePassage(std. : string type): Passage* Maze(std: string mazeFile) GetRoom(int row, int col) : Room* o GetNumberRows) int o GetNumberCols) int ~Maze() This class holds the information for the Maze. The Maze is a two-dimensional array of Rooms represented by a Room**. You will need to read the information for the Maze from an input file, assemble the information into Room objects, and add them to the array In addition to the parameterized constructor and a destructor, this class should have the following methods: LoadMaze () o This private helper function is used to read the file and create the two-dimensional array of Room objects. CreatePassage() o This private helper function takes in a string of-, '+,or an item need to open a door, and returns a pointer to an appropriate Passage object. o Takes in a position in terms of a row and col and returns a pointer to the Room object at that location in the Maze o Simple getter methods that return the number of rows and columns in the maze GetRoom (int row, int col) GetNumberRows GetNumberCols () Data format: A maze is specified by an input file with the following format: Row_count,Column_count Room_name, North_passageway, East_passageway, South_passageway, West_passageway,list_of_items_in_room The first line of the input file is the number of rows (Row_count) and the number of columns (Column_count) in the maze. The first line is followed by Row_count x Column_count lines with each line representing a different Room in the maze. Each room has a name, four connected passageways, and a list of items in that room. Each passageway in a room is one of three types: 1. "- : No passage is allowed 2. "+": Passage is open 3. "item_needed to_open_passageway": Requires the item(s) specified to open the door The input file for our example maze would look like the following: The Start,-,+,red_key, -,axe blue key The Landing, -,+,-,t Master Bedroom,-,,+,red_key The Kitchen, red_key- The Hall,-,+ The Exit! The Maze Class C) Maze o rooms: Roomtt rows: int cols: int maze File: std:ifstream LoadMaze): void CreatePassage(std. : string type): Passage* Maze(std: string mazeFile) GetRoom(int row, int col) : Room* o GetNumberRows) int o GetNumberCols) int ~Maze() This class holds the information for the Maze. The Maze is a two-dimensional array of Rooms represented by a Room**. You will need to read the information for the Maze from an input file, assemble the information into Room objects, and add them to the array In addition to the parameterized constructor and a destructor, this class should have the following methods: LoadMaze () o This private helper function is used to read the file and create the two-dimensional array of Room objects. CreatePassage() o This private helper function takes in a string of-, '+,or an item need to open a door, and returns a pointer to an appropriate Passage object. o Takes in a position in terms of a row and col and returns a pointer to the Room object at that location in the Maze o Simple getter methods that return the number of rows and columns in the maze GetRoom (int row, int col) GetNumberRows GetNumberCols () Data format: A maze is specified by an input file with the following format: Row_count,Column_count Room_name, North_passageway, East_passageway, South_passageway, West_passageway,list_of_items_in_room The first line of the input file is the number of rows (Row_count) and the number of columns (Column_count) in the maze. The first line is followed by Row_count x Column_count lines with each line representing a different Room in the maze. Each room has a name, four connected passageways, and a list of items in that room. Each passageway in a room is one of three types: 1. "- : No passage is allowed 2. "+": Passage is open 3. "item_needed to_open_passageway": Requires the item(s) specified to open the door The input file for our example maze would look like the following: The Start,-,+,red_key, -,axe blue key The Landing, -,+,-,t Master Bedroom,-,,+,red_key The Kitchen, red_key- The Hall,-,+ The Exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions