本文整理汇总了C++中Space::playersOnSpaceToString方法的典型用法代码示例。如果您正苦于以下问题:C++ Space::playersOnSpaceToString方法的具体用法?C++ Space::playersOnSpaceToString怎么用?C++ Space::playersOnSpaceToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Space
的用法示例。
在下文中一共展示了Space::playersOnSpaceToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printRowWithCurrentPlayers
//print out each spaces current players on that space, centered and ending with a |
void Game_Board::printRowWithCurrentPlayers(int numSpaces, int firstSpace, bool isReverse){
int padding = SPACE_WIDTH -2;
std::stringstream ss;
//run in regular order if not printing in reverse
if(!isReverse){
for(int i = 0; i < numSpaces; i++){
Space current = spaces[firstSpace + i]; //gets current space
std::string result = current.playersOnSpaceToString();
std::cout << "|" << std::left << std::setw(padding) << centerString(result);
}
std::cout << "|" << std::endl; // right side ending bracket
//else print the spaces as if in reverse order
}else{
for(int i = 0; i < numSpaces; i++){
Space current = spaces[firstSpace - i]; //gets current space
std::string result = current.playersOnSpaceToString(); //gets current players on the space
std::cout << "|" << std::left << std::setw(padding) << centerString(result);
}
std::cout << "|" << std::endl; // right side ending bracket
}
}
示例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;
}