/* * Copyright (C) 2016 PTM * * Object Oriented Programming Course Example File. * * Created: 02/02/2016 * Authors: Pasi Manninen */ using System; using System.Collections.Generic; namespace T6 { public class Invoice { public string Customer { get; set; } public double Total => ComputeTotal(); public int TotalItems => CountTotalItems(); public List Items { get; set; } = new List(); private double ComputeTotal() { double total = 0; foreach(InvoiceItem item in Items) { total += item.Total; } return total; } private int CountTotalItems() { return Items.Count; } public void PrintInvoice() { Console.WriteLine("Customer {0}'s invoice:", Customer); Console.WriteLine("================================="); foreach(InvoiceItem item in Items) { Console.WriteLine(item.ToString()); } Console.WriteLine("================================="); Console.Write("Total : " + Total + " euros"); } } }