static void Main(string[] args)
 {
     IPayment kebab = new Payment("kebabcheta", 6);
     IPayment kufte = new Payment("kifteta", 6);
     List<IPayment> pokupki = new List<IPayment>();
     pokupki.Add(kebab);
     pokupki.Add(kufte);
     Customer a = new Customer("Pepa", "Petrova", "Pitkova", "8101111120",
         "*****@*****.**", "0989888888", "gr.Sofia,kv. Zaharna fabrika", CustomerType.Diamond,pokupki);
     Customer b = a.Clone() as Customer;
     IEnumerable<IPayment> payB = b.Payments;
     IPayment pastyrmichka = new Payment("pastyrma", 15);
     b.AddPayment(pastyrmichka);
     Console.WriteLine(a.Payments.Count());
     Console.WriteLine(b.Payments.Count());
 }
示例#2
0
 public object Clone()
 {
     List<IPayment> clonedPayments = new List<IPayment>();
     foreach (var payment in this.Payments)
     {
         var clonedPayment = new Payment(payment.ProductName, payment.Price);
         clonedPayments.Add(clonedPayment);
     }
     Customer cloned = new Customer(this.FirstName, this.MiddleName, this.LastName,
         this.ID, this.Mail, this.MobilePhone, this.PermanentAddress, this.CustomerType, clonedPayments);
     return cloned;
 }