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


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

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


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

示例1: main


//.........这里部分代码省略.........
					cout << "You are not holding anything." << endl;
				}
				cin.ignore(256, '\n');
				break;
			}
			case 4:		//pick up item
			{
				//test if object already being held
				if (currentObject == NULL)
				{
					if ((location == cave1 || location == cave2) && !flashlightOn)	//in cave but no light
					{
						cout << "It's too dark to see any items. Some light may help." << endl;
					}
					//test for cave location and flashlight status   OR   any other location
					else if (((location == cave1 || location == cave2) && flashlightOn) || (location != cave1 || location != cave2))
					{
						//test for items
						if (location->objectsPresent())
						{
							int choice = -1;
							int getComplete = false;
							while (choice = -1 && getComplete == false)
							{
								location->displayObjects();		//display item list
								cout << endl;
								cout << "Enter the Item # and press enter." << endl;
								choice = getInput();			//user selects item
								if (choice > -1 && choice < 10)	//test for valid choice
								{
									if (location->getObject(choice) != NULL)
									{
										currentObject = (location->getObject(choice)); //add object to currentObject
										location->removeObject(choice);		//remove object from space
										cout << "You are now holding " << currentObject->getName() << endl;
										getComplete = true;
									}
									else
									{
										cout << "Incorrect choice. Try again" << endl;
										choice = -1;
									}
								}
							}
						}
						else
						{
							cout << "No items to pick up here." << endl;
						}
					}
					/*else if ((location == cave1 || location == cave2) && !flashlightOn)
					{
						cout << endl << location->getLook1() << endl << endl;
					}*/
					//else
						//{
						//	//display location view
						//	cout << endl << location->getLook1() << endl << endl;
						//	//display objects present
						//	location->displayObjects();
						//}
				}
				else
				{
					cout << "You cannot pick up another item because you are already holding something" << endl;
				}
开发者ID:giorosati,项目名称:CS162_Final_Project,代码行数:67,代码来源:main.cpp


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