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


C++ Space::getName方法代码示例

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


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

示例1: printRowWithName

	//print out each spaces name, centered and ending with a |
	void Game_Board::printRowWithName(int numSpaces, int firstSpace, bool isReverse){
		
		int padding = SPACE_WIDTH -2;

		if(!isReverse){
			for(int i = 0; i < numSpaces; i++){
				Space current = spaces[firstSpace + i]; //gets current space
				std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName());
			}
			std::cout << "|" << std::endl; // right side ending bracket
		} else{
			for(int i = 0; i < numSpaces; i++){
				Space current = spaces[firstSpace - i]; //gets current space
				std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName());
			}
			std::cout << "|" << std::endl; // right side ending bracket
		}
	}
开发者ID:jpugliesi,项目名称:PA5,代码行数:19,代码来源:Game_Board.cpp

示例2: printMiddleRow

	//Prints middle row with two spaces on either edge of the baord
	//those spaces are in spaces[space1Index] and spaces[space2Index]
	void Game_Board::printMiddleRow(int space1Index, int space2Index){

		//print out each spaces name, centered and ending with a |
		int padding = SPACE_WIDTH-2;

		for(int i = 0; i < SPACES_IN_ROW; i++){
			if(i == 0){
				Space current = spaces[space1Index];
				std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName()) << "|";
			} else if(i == 10){
				Space current = spaces[space2Index];
				std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName()) << "|";
			}else{
				int x = 1;
				if(i == 9) x = 2;
				for(int j = 0; j < SPACE_WIDTH - x; j++){
					std::cout << " ";
				}
			}
		}
		std::cout << std::endl; // right side ending bracket

		//print out each spaces Owner, centered and ending with a |
		for(int i = 0; i < SPACES_IN_ROW; i++){
			if(i == 0){
				Space current = spaces[space1Index];
				if(current.isOwnable()){
					std::string owner = current.getOwner();
					std::string ownerLine = "Owner: " + owner;
					std::cout << "|" << std::left << std::setw(padding) << centerString(ownerLine) << "|";
				}else{
					std::cout << "|";
					for(int j = 0; j < SPACE_WIDTH - 2; j++){
						std::cout << " ";
					}
					std::cout << "|";
				}
			} else if(i == 10){
				Space current = spaces[space2Index];
				if(current.isOwnable()){
					std::string owner = current.getOwner();
					std::string ownerLine = "Owner: " + owner;
					std::cout << "|" << std::left << std::setw(padding) << centerString(ownerLine) << "|";
				} else{
					std::cout << "|";
					for(int j = 0; j < SPACE_WIDTH - 2; j++){
						std::cout << " ";
					}
					std::cout << "|";
				}
			}else{
				int x = 1;
				if(i == 9) x = 2;
				for(int j = 0; j < SPACE_WIDTH - x; j++){
					std::cout << " ";
				}
			}
		}
		std::cout << std::endl;

		for(int i = 0; i < SPACES_IN_ROW; i++){
			if(i == 0 || i == 10){
				std::cout << "|";
				for(int j = 0; j < SPACE_WIDTH-2; j++){
					std::cout << " ";
				}
				std::cout << "|";
			}else{
				int x = 1;
				if(i == 9) x = 2;
				for(int j = 0; j < SPACE_WIDTH - x; j++){
					std::cout << " ";
				}
			}
		}
		std::cout << std::endl;

		//Prints out the players currently on each space
		for(int i = 0; i < SPACES_IN_ROW; i++){
			if(i == 0){
				Space current = spaces[space1Index];
				std::string result = current.playersOnSpaceToString();
				std::cout << "|" << std::left << std::setw(padding) << centerString(result) << "|";
			} else if(i == 10){
				Space current = spaces[space2Index];
				std::string result = current.playersOnSpaceToString();
				std::cout << "|" << std::left << std::setw(padding) << centerString(result) << "|";
			}else{
				int x = 1;
				if(i == 9) x = 2;
				for(int j = 0; j < SPACE_WIDTH - x; j++){
					std::cout << " ";
				}
			}
		}
		std::cout << std::endl;

	}
开发者ID:jpugliesi,项目名称:PA5,代码行数:100,代码来源:Game_Board.cpp


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