Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS A C++ ASSIGNMENT Programming assignment 10: Maze Solvability Assigned: 11/12 Checkin: 11/14 (by email by 5pm) - Start a new project, define your

THIS IS A C++ ASSIGNMENT

Programming assignment 10: Maze Solvability

Assigned: 11/12 Checkin: 11/14 (by email by 5pm) - Start a new project, define your maze class. Make sure you can load and display an ASCII map given a provided file Due: 11/19 by email before the start of class

Libraries you may use:

iostream

fstream

string

The use of any other libraries will result in the loss of points.

Purpose: The purpose of this assignment is to give us all a bit more practice working with recursion, specifically flood fill! In addition to performing traditional flood applications, a flood fill can be used to determine if it is possible to solve a maze: Start the flood at the 'Start' location, and see if your flood makes it to the 'end' location!

Task: First, you will need to define a maze class with the following member attributes and functionality:

Your maze class will minimally require the following attributes:

struct point - you will need to define a point struct, containing a row and a column. This will be used by your program to determine start and end locations.

pixel** plan - a dynamic 2D array that holding an ASCII representation of your maze

int rows - number of rows in your dynamic array

int cols - number of columns in your dynamic array

string outputFile - a string of the output file you will be generating. This will be derived from the input file (see constructor below). Simply add a ".flooded" to the end of the input file name.

point start - a row and column position of the starting point

point end - a row and a column position of the end point

Your maze class should also minimally contain the following member functions:

maze(string infile) - parameterized constructor. Note, there should be no default constructor. Open the file specified by infile, and read in the data. The first 2 values in the file will be cols then rows. The next 4 values will be row and colum pairs defining the start and end points of this maze. You will then need to create your dynamic 2D array and load data from the input file. It is safe to assume that a space means the area is clear, and pipes '|', hyphens '-', and plus signs '+' define maze walls/edges.

void flood(char c) - Your flood should start at point start, and should flood the maze with the character c.

void storeResult() - this function outputs your maze data to file. It should be in the same format you read it in, but show the results of the flood.

bool isSolveable(char c) - this function should check to see if the flood reached the end position. You will need to pass it the same character you used for the flood. It is a helper function so main() can check to see if the maze is solveable.

Your main file will be very sparse for this assignment: Start by asking the name of the file to load. You will use this information to create a maze object. Your main will then need to prompt the user for a flood character, flood it via the flood function, print out whether or not the maze is solveable, and then finally save it via the storeResult function. As such, you will not need to implement any further function in your main (unless you feel it would be helpful).

Sample input files can be found here: maze1.txt, maze2.txt

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_2

Step: 3

blur-text-image_3

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

=+ b. A change in weather patterns increases the depreciation rate.

Answered: 1 week ago