我认为有权访问数据是正常的愿望。如果我已经用于这个目标,我应该在Record
课堂上创建 getter/setter吗?或者需要做什么?Storage
Record
public class Storage {
List<Record> record;
public Storage(){
this.record = new ArrayList<Record>();
}
public void addRecord(Record record) {
this.record.add(record);
}
public Record getRecord(int number){
return this.record.get(number);
}
public class Record {
private int number;
private int count;
private Object code;
/* public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
} */
public Record(int number, int count, Object code) {
this.number = number;
this.count = count;
this.code = code;
}
@Override
public String toString() {
return (this.number+" "+this.code+" "+ this.count);
}
}