我的包裹上有这些课程:
1. Class Goods with attributes (name, price, id) //Goods id is unique, but the name can be the same
2. Class Storage with attributes (Goods gArray[3])
3. Class Store with attributes (name, ArrayList<Storage>) //Store name is unique
4. Class StoreSystem with attributes (ArrayList<Store>)
我想将商品插入属于某个商店的存储中。我已经成功地将Store插入到ArrayList中,但还没有找到插入Goods的方法。
添加商店的代码如下:
public String addStore(String storeName) {
String output = "";
if(storeCheck(storeName)) { //storeCheck used to check whether the store name exist/not.
output = "store already exist!";
}
else {
Store s1 = new Store();
Storage st1 = new Storage();
s1.setStoreName(storeName);
s1.setStorageList(null);
st1.setGArray(null);
listOfStore.add(s1);
listOfStorage.add(st1);
output = "Store added";
}
return output;
}
慕丝7291255
梦里花落0921
12345678_0001
相关分类