我正在为 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 类应该是公共的还是默认访问更好?一个人,一个私人的人应该是公共的,即使这里的含义并不完全相同,这不是有点奇怪。
当我的 IDE 发出警告时,我应该如何处理
inventory = Collections.synchronizedCollection( new LinkedList() );
?它警告我的类型安全。
谢谢