I have these class on my package:
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>)
I want to insert Goods into Storage which belong to certain Store. I already succeed in inserting the Store to ArrayList, but haven't found the way to insert the Goods.
Here's the code for adding the store:
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;
}
Storagein aStore? Something like astorageIdor something?