How to give each store object it's own arrayList of stock?

前端 未结 1 739
花落未央
花落未央 2021-01-23 17:14

Finding this one tough, basically I have three classes: Store class, Stock class and then the class for the GUI. When a store is created, I want it to have it\'s very own arrary

1条回答
  •  再見小時候
    2021-01-23 17:54

    In the constructor of Store, you have

    ArrayList  stockItems = ...
    

    That is actually creating a local variable stockItems, instead of changing the field. To make it work use just

    stockItems = ...
    

    0 讨论(0)
提交回复
热议问题