Skip to content

Instantly share code, notes, and snippets.

@vkhorikov
Last active August 29, 2015 14:24
Show Gist options
  • Save vkhorikov/06c133fd09b12b20bef8 to your computer and use it in GitHub Desktop.
Save vkhorikov/06c133fd09b12b20bef8 to your computer and use it in GitHub Desktop.
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