Tuesday, December 8, 2009

Finding a Path algorithm - Maze Class Declaration

/*
Title: Maze Class Declaration
Author: Daniel J. Tanner
Class: CS 2420 - Data Abstraction & Problem Solving w/ C++
Date: October 17th, 2005 (latest update)
*/

#ifndef TANNMAZE_H
#define TANNMAZE_H

/*This maze will be made up of several individual squares (represented by
characters).
C = a clear space the creature can walk thru
P = the correct path as travelled by the creature from the entrance to the
exit
X = exit of maze
W = a wall that the creature cannot walk through.
S = start of maze
V = a clear space that the creature has visited, but lead to a dead end.
*/

#include
#include
#include
#include
#include
using namespace std;

//Define enumerated data type for squares
enum mazeSquare{CLEAR, WALL, EXIT, START, PATH, VISITED};

//Special structure for handling incoming and outgoing squares
struct Coord
{
int x, y;
};

//Class TannMaze Declaration
class TannMaze
{
private:
mazeSquare **maze;
int mazeHeight_;
int mazeWidth_;
Coord start_;
Coord end_;

public:
//Error class
class MazeError
{
private:
string problem_;
public:
MazeError(string problem) {problem_ = problem;}
string getProblem() {return problem_;}
};

void mark(const Coord &sqLoc, mazeSquare demarcation);
void displayMaze()const;

//inline get & set functions
int getHeight()const {return mazeHeight_;}
int getWidth()const {return mazeWidth_;}
Coord getStart()const {return start_;}
Coord getEnd()const {return end_;}
mazeSquare checkCoord(int y, int x) {return maze[y][x];}
void setStart(Coord &start) {start_ = start;}
void setEnd(Coord &end) {end_ = end;}
void setHeight(int height) {mazeHeight_ = height;}
void setWidth(int width) {mazeWidth_ = width;}

//Maze Generator functions
void generateMaze(int width, int height, Coord &start, Coord &end);
void generateMaze(string filename);
void generateMaze();

//Constructors
TannMaze();
TannMaze(int width, int height, Coord &start, Coord &end);
TannMaze(string filename);

//Destructor
~TannMaze();
};

#endif

No comments:

Post a Comment