现在我遇到了 ArrayDeque 指定元素的问题。
Storages.add(new Storage("Furniture storage", 5, 58));
首先是存储类型。下一层,最后一层是doorNumber。
现在我想将特定的 ArrayDeque 元素更改Floor
为另一个元素。
例如从第二个列表项
Meat storage 1 18
到
Meat storage 7 18
有我的主要课程
ArrayDeque<Storage> Storages = new ArrayDeque<Storage>();
Storage storage_obj = new Storage();
Storages.add(new Storage("Furniture storage", 5, 58));
Storages.add(new Storage("Meat storage", 1, 18));
Storages.add(new Storage("Hardware storage", 4, 41));
Storages.add(new Storage("Technique storage", 2, 27));
Storages.add(new Storage("Vegetable storage", 8, 88));
Storages[1] = storage_obj.setFloor(7);
System.out.println("Whole storages list");
outputStorages(Storages);
有存储类
public class Storage {
private String type;
private int floor;
private int doorNumber;
public Storage(){
this("------", 0,0);
}
public Storage(String type_t, int floor_t, int doorNumber_t){
type = type_t;
floor = floor_t;
doorNumber = doorNumber_t;
}
void setType(String type){
this.type = type;
}
String getType(){
return this.type;
}
void setFloor(int floor){
this.floor = floor;
}
int getFloor(){
return this.floor;
}
void setDoorNumber(int doorNumber){
this.doorNumber = doorNumber;
}
int getDoorNumber(){
return this.doorNumber;
}
}
Ps 不要因为我的语法来评判我,英语不是我的母语^^