设计一货物类,字段1:名称(String);字段2:入货时间(Date).编写代码,使得一货物数组中的多个货物对象根据用户选项既可由名称排序也可由入货时间排序。在测试程序中测试货物类实现的功能(可由用户输入三种货物的信息进行测试)。
public class Goods {
String name; //货物名称
Date entryTime; //入货时间
//Getter和Setter
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getEntryTime() {
return entryTime;
}
public void setEntryTime(Date entryTime) {
this.entryTime = entryTime;
}
}