Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Events
using System;

namespace Events
{
class Program
{
Expand All @@ -18,17 +20,38 @@ internal Product Product
static void Main(string[] args)
{
Product product = new Product("Some product name", 0);

/*
* TODO #6 Назначить обработчики событий в текущем контексте
*/
product.NameChanged += Product_NameChanged;
product.Name = "Table";
product.Name = "Window";

product.PriceChanged += Product_PriceChanged;
product.Price = 1000;
product.Price = 2000;
/*
* TODO #7 Выполнить с экземпляром класса Product действия,
* приводящие к возникновению описанных Вами событий
*/
}



private static void Product_NameChanged(object sender, ProductEventArgs e)
{
Product product = sender as Product;
Console.WriteLine("У продукта '{0}' было изменено название на '{1}'!", e.OldValueName, e.NewValueName);
//throw new NotImplementedException();
}

private static void Product_PriceChanged(object sender, ProductEventArgs e)
{
Product product = sender as Product;
Console.WriteLine("У продукта была изменена стоимость с '{0}' на '{1}'!", e.OldValuePrice, e.NewValuePrice);
//throw new NotImplementedException();
}
/*
* TODO #8 Добавить определение обработчиков событий
*/
Expand Down