2
我使用ArrayDeque创建了一个基本的库存系统,其中的东西被推入库存。ArrayDeque包含Object?
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'放在那里? –
你想检查集合中是否有某个对象,但是你不知道运行时该对象是什么? –