⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 building.h

📁 迷宫问题
💻 H
字号:
#if !defined BUILDING_H
#define BUILDING_H

#include <string>
#include <fstream>
#include <iostream>

#include "cell.h"
#include "array_queue.h"
#include "llstack.h"
using namespace std;


class Building
{
public:
	Building (string filename);
	virtual bool escape()=0;				//precondition:start from the initial position
														//postcondition:arrive at the halipad or parking, return 1
														//OR if there is no possible way, print out a fail message, return 0
	void printMap(string filename="escape.txt") const;           //Print the map with escaping routine

protected:
	Cell currentSquare, initialSquare, exitSquare[2];
	char **map;           
	int row_size, col_size;

};



////Derived class Stack_Building, using stacks to impement escape()
/////////////////////////////////////////////////////////////////////////////////////

class Stack_Building: public Building
{
public:
	Stack_Building(string filename);
	bool escape();
private:
	LLStack<Cell> route;			//store the escaping route
	LLStack<Cell> unvisited;		 //store the unvisited squares 
	bool pushUnvisited(int row, int col);		//pop the adjacent unvisited squares to the stack
	bool Stack_Building::deadWay(int x, int y);			//check if the square with coordinates x and y is dead
};




////Derived class Queue_Building, using queues to impement escape()
////////////////////////////////////////////////////////////////////////////////////////

class Queue_Building: public Building
{
public:
	Queue_Building(string filename);
	bool escape();	
private:
	ArrayQueue<Cell> unvisited;
};

class Opt_Building: public Building
{
public:
	Opt_Building(string filename);
	bool escape();
};


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -