【发布时间】:2012-06-14 08:25:42
【问题描述】:
我正在为 Persons 开发一个课程,我有一两个关于它的问题。
/**
* ADT for persons which is completed which subclasses
* to creating actors with specific properties
*/
public class Person {
/**
* Name of the Person.
*/
public String name;
/**
* The World which this Person is associated with.
*/
public World world;
/**
* Tells where this Person is at the moment.
*/
public Place where;
/**
* The inventory, contains Things.
*/
public Collection<Thing> inventory;
/**
* Shows how the Person looks like
*/
public Image appearance;
/**
* Create Person named `name' in world `world'.
*
* @param world The world where the Person is created.
* @param name Name of the Person.
* @param app An image used to display the Person.
*/
public Person( World world, String name, Image app ) {
this.world = world;
this.name = name;
this.appearance = app;
where = world.defaultPlace();
where.enter( this );
inventory = Collections.synchronizedCollection( new LinkedList() );
}
...
Person 类应该是公共的还是默认访问更好?一个Person,一个privatePerson 应该是public,这不是有点奇怪,尽管这里的意思并不完全一样。
当我的 IDE 警告
inventory = Collections.synchronizedCollection( new LinkedList() );时,我应该如何处理这个问题?它警告我的类型安全。
谢谢
【问题讨论】:
标签: java model-view-controller model game-engine