关于JAVA代码 求教
publicvoidaddEntity(Entityentity){//Preconditions;entitynotnullassert(entity!=null);/...
public void addEntity(Entity entity)
{
// Preconditions; entity not null
assert(entity!=null);
// Method proper
removeEntity(entity.getEntityID());
entityMap.put(entity.getEntityID(), entity);
entityVector.add(entity);
if(entity instanceof Drawable) drawableVector.add(entity);
if(entity instanceof UserInfo) userInfoVector.add(entity);
if(entity instanceof Claim) claimVector.add(entity);
if(entity instanceof ChatState) chatStateVector.add(entity);
}
解释下 谢谢了 展开
{
// Preconditions; entity not null
assert(entity!=null);
// Method proper
removeEntity(entity.getEntityID());
entityMap.put(entity.getEntityID(), entity);
entityVector.add(entity);
if(entity instanceof Drawable) drawableVector.add(entity);
if(entity instanceof UserInfo) userInfoVector.add(entity);
if(entity instanceof Claim) claimVector.add(entity);
if(entity instanceof ChatState) chatStateVector.add(entity);
}
解释下 谢谢了 展开
1个回答
展开全部
以下是我加的注释,希望对你有帮助。
public void addEntity(Entity entity)
{
// Preconditions; entity not null
assert(entity!=null); //当entity!=null为true时,程序继续执行,否则抛出java.lang.AssertionError,程序终止
// Method proper
removeEntity(entity.getEntityID()); //移除指定实体id的entity对象
entityMap.put(entity.getEntityID(), entity); //在entityMap集合中加入以实体id为主键,以对象entity为值的键值对
entityVector.add(entity); //将entity写入entityVector集合中
if(entity instanceof Drawable) drawableVector.add(entity); //如果对象entity是类Drawable的实例,则将此对象加入drawableVector集合中
if(entity instanceof UserInfo) userInfoVector.add(entity);//如果对象entity是类UserInfo的实例,则将此对象加入userInfoVector集合中
if(entity instanceof Claim) claimVector.add(entity);//如果对象entity是类Claim的实例,则将此对象加入claimVector集合中
if(entity instanceof ChatState) chatStateVector.add(entity);//如果对象entity是类ChatState的实例,则将此对象加入chatStateVector集合中
}
public void addEntity(Entity entity)
{
// Preconditions; entity not null
assert(entity!=null); //当entity!=null为true时,程序继续执行,否则抛出java.lang.AssertionError,程序终止
// Method proper
removeEntity(entity.getEntityID()); //移除指定实体id的entity对象
entityMap.put(entity.getEntityID(), entity); //在entityMap集合中加入以实体id为主键,以对象entity为值的键值对
entityVector.add(entity); //将entity写入entityVector集合中
if(entity instanceof Drawable) drawableVector.add(entity); //如果对象entity是类Drawable的实例,则将此对象加入drawableVector集合中
if(entity instanceof UserInfo) userInfoVector.add(entity);//如果对象entity是类UserInfo的实例,则将此对象加入userInfoVector集合中
if(entity instanceof Claim) claimVector.add(entity);//如果对象entity是类Claim的实例,则将此对象加入claimVector集合中
if(entity instanceof ChatState) chatStateVector.add(entity);//如果对象entity是类ChatState的实例,则将此对象加入chatStateVector集合中
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询