Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Edit: Removed snarkyness and attitude :)</p> <p>First you need an order (hint you are going to need a class for that). Now the order needs to be attched to a user. So add a field of type User. That takes care of one order one user. (Note that a user can make more than one order)</p> <p>So now you order is missing lines. Add another member variable that is a list of line types. Now in your order you need to add methods to add, remove and query order lines.</p> <p>Edit: The question was raised what was meant by "add a field". Add a field means add a property or private member. When you are doing this you are doing the technical term of composition. Composition is commonly explained as a "has a" relationship. So an order "has a user" and "has a list of order lines"</p> <pre><code>Class User() { public string firstName { get; set; } public string lastName {get; set; } public int id { get; set;} } Class OrderLine() { } Class Order() { private List&lt;OrderLine&gt; orderLines; public User submitter { get; set;} public Order() { orderLines = new List&lt;OrderLine&gt;(); } public void AddOrderLine(OrderLine newOrderLine) { this.orderLines.Add(newOrderLine); } public IList&lt;OrderLine&gt; GetOrderLines() { return this.orderLines; } } </code></pre> <p>Example</p> <pre><code>User customer1 = new User(); // Initialize customer1 values... Order someOrder = new Order(); someOrder.submitter = customer1; someOrder.AddOrderLine(new OrderLine()); </code></pre> <p>EDIT: Changed Member class to User class</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