【发布时间】:2012-12-05 10:30:50
【问题描述】:
我正在创建一个带有 ArrayDeque 的基本库存系统,其中的东西被推送到库存中。
Couch couch1 = new Couch("I wouldn't sit on it.", 100, true);
roomList[0].inventory.add(couch1);
我正在检查一个物品是否在这样的房间里。
if (input.matches(".*look.*"))
{
if(input.matches(".*Couch.*"))
{
if(roomList[currentRoom].inventory.contains(???))
{
//code to be executed.
}
}
}
我在 ???为了检查库存ArrayDeque是否包含对象couch1?如果这不可能,有没有更好的方法来做到这一点?
【问题讨论】:
-
你为什么不把
couch1放在那里? -
您想检查集合中是否有某个对象,但您不知道该对象在运行时是什么?
标签: java arraydeque