static void Main(string[] args) { MyNewCollection <Trial> newCol1 = new MyNewCollection <Trial>(); MyNewCollection <Trial> newCol2 = new MyNewCollection <Trial>(); newCol1.Name = "First"; newCol2.Name = "Second"; Journal joun1 = new Journal(); Journal joun2 = new Journal(); //подписка на события = присоединение обработчика к event-объекту newCol1.CollectionCountChanged += new CollectionHandler(joun1.CollectionCountChanged); newCol1.CollectionReferenceChanged += new CollectionHandler(joun2.CollectionReferenceChanged); newCol2.CollectionCountChanged += new CollectionHandler(joun1.CollectionCountChanged); newCol2.CollectionReferenceChanged += new CollectionHandler(joun2.CollectionReferenceChanged); newCol1.Add(); newCol1.Add(); newCol1.Add(); newCol2.Add(); newCol2.Add(); newCol2.Add(); newCol1.Delete(); newCol2.ChangeValue(1); newCol1.ChangeValue(0); Console.WriteLine(); Console.WriteLine("Проверка"); Console.WriteLine(); Console.WriteLine("Вывод первой коллекции:"); newCol1.Show(); Console.WriteLine(); Console.WriteLine("Вывод второй коллекции:"); newCol2.Show(); Console.WriteLine(); Console.WriteLine("Вывод первого журнала:"); joun1.ToString(); Console.WriteLine(); Console.WriteLine("Вывод второго журнала:"); joun2.ToString(); }
static void Main(string[] args) { int origWidth = Console.WindowWidth * 2; int origHeight = Console.WindowHeight * 2; Console.SetWindowSize(origWidth, origHeight); MyNewCollection firstList = new MyNewCollection("Первая коллекция", 5); MyNewCollection secondList = new MyNewCollection("Вторая коллекция", 5); Journal firstJournal = new Journal(); firstList.CollectionCountChanged += new CollectionHandler(firstJournal.CollectionCountChanged); //+=firstJournal.CollectionCountChanged firstList.CollectionReferenceChanged += new CollectionHandler(firstJournal.CollectionReferenceChanged); Journal secondJournal = new Journal(); firstList.CollectionReferenceChanged += new CollectionHandler(secondJournal.CollectionReferenceChanged); secondList.CollectionReferenceChanged += new CollectionHandler(secondJournal.CollectionReferenceChanged); firstList.Add(); firstList.Add(); secondList.Add(); firstList.Remove(2); secondList.Remove(2); firstList[2] = new InsuranceCompany("Страховая компания1", "Город1", 150, 1000000, "Регион1"); secondList[3] = Organization.RandomOrganization(); firstList[3] = new InsuranceCompany("Страховая компания2", "Город2", 100, 5000000, "Регион2"); Console.WriteLine("=== Первый журнал: ==="); Console.WriteLine(firstJournal); Console.WriteLine(); Console.WriteLine("=== Второй журнал: ==="); Console.WriteLine(secondJournal); Console.ReadLine(); }
public static void Main(string[] args) { var col1 = new MyNewCollection("FirstCol", 10); var col2 = new MyNewCollection("SecondCol", 10); var journal1 = new Journal(); col1.CollectionCountChanged += journal1.OnCollectionCountChanged; col1.CollectionReferenceChanged += journal1.OnCollectionReferenceChanged; var journal2 = new Journal(); col1.CollectionReferenceChanged += journal2.OnCollectionReferenceChanged; col2.CollectionReferenceChanged += journal2.OnCollectionReferenceChanged; col1[5] = (Food) new Food().CreateRandom(); col1.Remove(5); col1.AddRandom(); Console.WriteLine(journal1); col2.Add((Food) new Food().CreateRandom()); col2[0] = (Food) new Food().CreateRandom(); Console.WriteLine(journal2); }