本文整理汇总了C++中Inventory::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::Count方法的具体用法?C++ Inventory::Count怎么用?C++ Inventory::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::Count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Is empty when constructed") {
REQUIRE(inventory.Has("sword") == false);
REQUIRE(inventory.Has("soul reaver") == false);
// Can receive one or more items") {
REQUIRE(inventory.Add("sword") == true);
REQUIRE(inventory.Has("sword") == true);
REQUIRE(inventory.Has("soul reaver") == false);
REQUIRE(inventory.Add("soul reaver") == true);
REQUIRE(inventory.Add("sword") == true);
REQUIRE(inventory.Has("sword") == true);
REQUIRE(inventory.Has("soul reaver") == true);
// Can return the number of items") {
REQUIRE(inventory.Count("sword") == 2);
REQUIRE(inventory.Count("soul reaver") == 1);
// Can equip items") {
REQUIRE(inventory.Equip("soul reaver", true) == true);
REQUIRE(inventory.IsEquipped("soul reaver") == true);
REQUIRE(inventory.Equip("sword", true) == true);
REQUIRE(inventory.IsEquipped("sword") == true);
REQUIRE(inventory.Equip("sword", false) == true);
REQUIRE(inventory.IsEquipped("sword") == false);
REQUIRE(inventory.Equip("sword", true) == true);
REQUIRE(inventory.Equip("nothing", true) == false);
REQUIRE(inventory.IsEquipped("nothing") == false);