Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I like your approach to the problem. So reading your questions:</p> <ul> <li><p>Each of this choices have a sound logic, so your choice depends on<br> how you want to structure your objects and how you want to use them. As a programmer I reccomend you use the second one or the third one. </p></li> <li><p>Yes, the Showroom could have an addCostumer method and in this case if you want to use the second or third choise it must have an addCostumer method if you'd like to add a Costumer to the storage.</p></li> </ul> <p>Using the third choise here is my sample code:</p> <pre><code>class Stock { /*...*/ } class Customer { /*...*/ } class Order { /*...*/ } class Showroom { protected List&lt;Stock&gt; StockList; protected List&lt;Customer&gt; CustomerList; protected List&lt;Order&gt; OrderList; public Showroom() { StockList = new List&lt;Stock&gt;(); CustomerList = new List&lt;Customer&gt;(); OrderList = new List&lt;Order&gt;(); } public virtual void addStock(Stock stock) { StockList.Add(stock); } public virtual void addCustomer(Customer customer) { CustomerList.Add(customer); } public virtual void addOrder(Order order) { OrderList.Add(order); } //... } class deskClerk : Showroom { public deskClerk() { CustomerList = new List&lt;Customer&gt;(); } public override void addCustomer(Customer customer) { CustomerList.Add(customer); } //... } </code></pre> <p>So I can reccomend you another thing:</p> <p>Every time you will work with objects give to each one his role and his tasks, and then every choise depends on the logic that you want to use. Choose the one you think will work and fit well in the context where you want to use it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload