public void solve( int x, int y ) {



	//primary base case
	if ( maze[x][y] .equals( EXIT1 )|| maze[x][y] .equals( EXIT2 )  ){
	    solved = true;
	    for (int i=0; i<h;i++){
		for(int j=0;j<w;j++){
		    if (maze[i][j]=="."){
			maze[i][j]=" ";
		    }
		}
	    }
	    System.out.println(this);
		try {
		    FileWriter f = new FileWriter("mazeSolution.txt");
		    f.write(toString());
		    f.close();
		}
		 catch(Exception e){}
	    System.exit(0);
	}
	//other base cases
	else if ( maze[x][y].equals(WALL1) || maze[x][y] .equals( WALL2) ||
		  maze[x][y] .equals( HERO) ||
		  maze[x][y] .equals( VISITED_PATH) ||  maze[x][y] .equals( START1 ) ||  maze[x][y] .equals( START2 )  ) {
	    return;
	}
	//otherwise, recursively solve maze from next pos over,
	//after marking current location
	else {
	    maze[x][y] = HERO;
	    //System.out.println( this ); //refresh screen

	    if ( !solved )
		solve( x, y-1 ); //solve from 1 pos up
	    if ( !solved )
		solve( x+1, y ); //solve from 1 pos to right
	    if ( !solved )
		solve( x, y+1 ); //solve from 1 pos down
	    if ( !solved )
		solve( x-1, y ); //solve from 1 pos to left

	    maze[x][y] = VISITED_PATH;
	    //System.out.println( this ); //refresh screen
	}
    }