diff --git a/Product.cs b/Product.cs index f68c8c9..d83a309 100644 --- a/Product.cs +++ b/Product.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Events { @@ -32,11 +32,17 @@ public string Name get { return name; } set { + ProductEventArgs args = new ProductEventArgs(name, value); name = value; /* * TODO #4 Инициировать уведомление об * изменении наименования */ + if (NameChanged != null) + { + NameChanged(this, args); + } + /**/ } } /// @@ -47,11 +53,17 @@ public decimal Price get { return price; } set { + ProductEventArgs args = new ProductEventArgs(price, value); price = value; /* * TODO #5 Инициировать уведомление об * изменении стоимости */ + if (NameChanged != null) + { + PriceChanged(this, args); + } + /**/ } } @@ -62,7 +74,9 @@ public decimal Price /* * TODO #3 Добавить определение событий */ - + public event EventHandler NameChanged; + public event EventHandler PriceChanged; + /**/ #endregion public Product(string name, decimal price)