I have a simple Store class that contains an Inventory object and a CashRegister object. In order to sell an item, the CashRegister object needs to access the Inventory object’s methods; namely, those which return a particular item’s price, quantity held in storage, etc. What’s the best way to give the CashRegister object access to the Inventory object’s methods?
Thank you.
Why? The
CashRegistercan exist and operate perfectly without anInventory. You can have aCashRegisterin a theater or a cinema, not only in aStore. This part of the logic you’re talking about should be part of the store.