当前位置: 首页>>代码示例>>C++>>正文


C++ Store::getWidth方法代码示例

本文整理汇总了C++中Store::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Store::getWidth方法的具体用法?C++ Store::getWidth怎么用?C++ Store::getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Store的用法示例。


在下文中一共展示了Store::getWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: integrityCheck

bool City::integrityCheck() {
	REQUIRE(properlyInitialized(), "Object 'City' was not properly properlyInitializedialized when calling integrityCheck()");

	bool integrity = true;
	std::vector<Coordinate> coordinates;

	for (std::list<House>::iterator ith = houses.begin(); ith != houses.end(); ith++){
		Coordinate location;
		CityObjects* ptr = &(*ith);
		if (getAdjecantStreet(ptr, Coordinate(0, 0)) == Coordinate(-1, -1)){
			House* houseptr = dynamic_cast<House*>(ptr);
			std::string houselocation = houseptr->getLocation().getString();
			o.print("\tERROR: House at location " + houselocation + " doesn't have a street linked to it.\n");
			integrity = false;
		}
		for (int x = 0; x < 2; x++){
			for (int y = 0; y < 2; y++){
				location = ith->getLocation();
				location.setX(location.getX()+x);
				location.setY(location.getY()-y);
				if (matrix.getObject(location.getX(), location.getY()) != &(*ith)){
					std::string houselocation = ith->getLocation().getString();
					o.print("\tERROR: House at location " + houselocation + " is supposed to be at " + location.getString() + " but is not.\n");
					integrity = false;
				}
				coordinates.push_back(location);
			}
		}
	}

	for (std::list<Fire_Department>::iterator itd = departments.begin(); itd != departments.end(); itd++){
		Coordinate location;
		CityObjects* ptr = &(*itd);
		if (getAdjecantStreet(ptr, Coordinate(0, 0)) == Coordinate(-1, -1)){
			Fire_Department* depptr = dynamic_cast<Fire_Department*>(ptr);
			std::string deplocation = depptr->getLocation().getString();
			o.print("\tERROR: Department at location " + deplocation + " doesn't have a street linked to it.\n");
			integrity = false;
		}
		for (int x = 0; x < 4; x++){
			for (int y = 0; y < 4; y++){
				location = itd->getLocation();
				location.setX(location.getX()+x);
				location.setY(location.getY()-y);
				if (matrix.getObject(location.getX(), location.getY()) != &(*itd)){
					std::string deplocation = itd->getLocation().getString();
					o.print("\tERROR: Department at location " + deplocation + " is supposed to be at " + location.getString() + " but is not.\n");
					integrity = false;
				}
				coordinates.push_back(location);
			}
		}
	}

	for (std::list<Store>::iterator itd = stores.begin(); itd != stores.end(); itd++){
		Coordinate location;
		CityObjects* ptr = &(*itd);
		Store* storeptr = dynamic_cast<Store*>(ptr);
		if (getAdjecantStreet(ptr, Coordinate(0, 0)) == Coordinate(-1, -1)){
			std::string storeLocation = storeptr->getLocation().getString();
			o.print("\tERROR: Store at location " + storeLocation + " doesn't have a street linked to it.\n");
			integrity = false;
		}
		for (int x = 0; x < storeptr->getWidth(); x++){
			for (int y = 0; y < storeptr->getLength(); y++){
				location = itd->getLocation();
				location.setX(location.getX()+x);
				location.setY(location.getY()-y);
				if (matrix.getObject(location.getX(), location.getY()) != &(*itd)){
					std::string storeLocation = itd->getLocation().getString();
					o.print("\tERROR: Store at location " + storeLocation + " is supposed to be at " + location.getString() + " but is not.\n");
					integrity = false;
				}
				coordinates.push_back(location);
			}
		}
	}

	for (std::list<Hospital>::iterator itd = hospitals.begin(); itd != hospitals.end(); itd++){
		Coordinate location;
		CityObjects* ptr = &(*itd);
		Hospital* hospitalPtr = dynamic_cast<Hospital*>(ptr);
		if (getAdjecantStreet(ptr, Coordinate(0, 0)) == Coordinate(-1, -1)){
			std::string hospitalLocation = hospitalPtr->getLocation().getString();
			o.print("\tERROR: Hospital at location " + hospitalLocation + " doesn't have a street linked to it.\n");
			integrity = false;
		}
		for (int x = 0; x < hospitalPtr->getWidth(); x++){
			for (int y = 0; y < hospitalPtr->getLength(); y++){
				location = itd->getLocation();
				location.setX(location.getX()+x);
				location.setY(location.getY()-y);
				if (matrix.getObject(location.getX(), location.getY()) != &(*itd)){
					std::string storeLocation = itd->getLocation().getString();
					o.print("\tERROR: Hospital at location " + storeLocation + " is supposed to be at " + location.getString() + " but is not.\n");
					integrity = false;
				}
				coordinates.push_back(location);
			}
		}
//.........这里部分代码省略.........
开发者ID:KrisTo-Corp,项目名称:ESS,代码行数:101,代码来源:City.cpp


注:本文中的Store::getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。