//program 4, maze class driver
//this is the actual program not just a test file
//brian jahns C1999
//cs252
#include <iostream.h>
#include <fstream.h>
#include "Maze.h"
int main()
{
ifstream bob; //declares a infilestream called bob
char name[33]; //array to store the file name
Maze maze1; //the actual maze to work with
cout<<"enter filename: "; //gets the file name
cin>>name;
cout<<endl;
bob.open(name); //opens the file
if(bob.bad()) //checks to make sure its a good file
{
cerr<<"ground control to major tom: bob is bad, i repeat, bob is bad"
<<endl;
return 1;
}
bob>>maze1; //reads the file into the maze class
//variable
bob.close(); //closes the file
cout<<endl<<"Here's the maze: "<<endl<<maze1;
//prints out the maze to start
if(maze1.findstart()) //finds the startpoint of the maze
{
if(maze1.solve()) //attempts to solve the maze
{
cout<<"Solution found!"<<endl; //if successful, returns 0
return 0;
}
else
{
cout<<"No solution found!"<<endl;
return 1; //if not there is no solution
}
}
else
{
cout<<"No startpoint found!"<<endl;
return 1; //this else is for the startpoint(..)
} //function call, if that call
} //returns false, there is no start
//point for the maze, return 1