本文整理汇总了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;
}