Last active
August 29, 2015 14:24
-
-
Save vkhorikov/06c133fd09b12b20bef8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Order | |
{ | |
private readonly List<OrderLine> _lines; | |
public Order() | |
{ | |
_lines = new List<OrderLine>(); | |
} | |
public decimal Amount | |
{ | |
get { return _lines.Sum(x => x.Price); } | |
} | |
public void AddLine(decimal price, Product product) | |
{ | |
_lines.Add(new OrderLine(price, product)); | |
} | |
} | |
public class OrderLine | |
{ | |
public decimal Price { get; private set; } | |
public Product Product { get; private set; } | |
public OrderLine(decimal price, Product product) | |
{ | |
Price = price; | |
Product = product; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment