Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- namespace _15._03
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Magazine std = new Magazine();// преобразовываем данные объекта с помощью метода toshortString
- //Console.WriteLine(std.ToShortString());
- //Console.WriteLine();
- //foreach (Frequency element in Enum.GetValues(typeof(Frequency)))//вывожу значения индексатора для значений индекса
- // Console.WriteLine($"{element} = {std[element]}");
- //Console.WriteLine();
- //std = new Magazine(new string("Glamur"), Frequency.Monthly, DateTime.MaxValue, 800);
- //Console.WriteLine(std.ToShortString());//присваиваю значения свойствам Magazine и вывожу с помощью метода ToString
- //Console.WriteLine();
- //std.AddArticles(
- //new Article("\nVogue", 3.5, new Person("Ivanova")),//с помощбю метода addArticles добавляю элементы в список статей и вывожу
- //new Article("\nElle", 7, new Person("Petrova")),
- //new Article("\nSadovik", 10, new Person("Kuznetzova")),
- //new Article("\nRussia", 20, new Person("Belova")));
- //Console.WriteLine(std.ToString());
- //Stopwatch a1 = new Stopwatch();//сравниваю время выполнения операций с одинаковым числом элем типа Articles
- //a1.Start();
- //Article[] P1 = new Article[40000];
- //for (int i = 0; i < P1.Length; i++)
- //{
- // P1[i] = new Article();
- //}
- //a1.Stop();
- //Console.WriteLine($"\nВремя первой операции: {a1.ElapsedMilliseconds}");
- //Stopwatch a2 = new Stopwatch();
- //a2.Start();
- //Article[,] P2 = new Article[400, 100];
- //for (int i = 0; i < 400; i++)
- //{
- // for (int j = 0; j < 100; j++)
- // {
- // P2[i, j] = new Article();
- // }
- //}
- //a2.Stop();
- //Console.WriteLine($"\nВремя второй операции: {a2.ElapsedMilliseconds}");
- //Stopwatch a3 = new Stopwatch();
- //a3.Start();
- //Article[][] P3 = new Article[5][];
- //{
- // for (int i = 0; i < 5; i++)
- // {
- // P3[i] = new Article[8000];
- // for (int j = 0; j < 8000; j++)
- // {
- // P3[i][j] = new Article();
- // }
- // }
- //}
- //a3.Stop();
- //Console.WriteLine($"\nВремя третьей операции: {a3.ElapsedMilliseconds}");
- ////////////////////////////////////////////// вторая часть
- //////////////////////1
- Console.WriteLine("New part of task \r\n /////////////////////////////////////////////////////////\r\n");
- Edition Ed1 = new Edition("Name1", new DateTime(2022,03,01), 10);
- Edition Ed2 = new Edition("Name1", new DateTime(2022,03,01), 10);
- Console.WriteLine(Ed1.Equals(Ed2));
- Console.WriteLine(Ed1 == Ed2);
- Console.WriteLine(string.Format(" Edition1: {0}, Edition2: {1} ", Ed1.GetHashCode(), Ed2.GetHashCode()));
- //////////////////////////////////////2
- try
- {
- Ed2._Circulation = -10;
- }
- catch (ArgumentOutOfRangeException ex)
- {
- Console.WriteLine(ex.Message);
- }
- ///////////////////////////////////////3
- Magazine Mag1 = new Magazine("Magazine1", Frequency.Monthly, new DateTime(2000, 01, 01), 1000);
- Mag1.AddArticles(new Article[3] { new Article("Art1", 7, new Person("Author of Art1")), new Article("Art2", 5, new Person("Author of Art2")), new Article("Art3", 10, new Person("Author of Art3")) });
- Mag1.AddEditors(new Person[3] { new Person("Author of Art1"), new Person("Author of Art2"), new Person("Author of Art3") });
- Console.WriteLine(Mag1.ToString());
- /////////////////////////////4
- Console.WriteLine(Mag1.GetEdition.ToString());
- /////////////////////////////////5
- ///если хочется проверить. что без дип копи данные меняются по ссылке во всех объектах, привязанных к ссылке
- ////Magazine Mag1Copy = Mag1;
- ////Mag1Copy.name = "Magazine234";
- ////Console.WriteLine(Mag1.ToString());
- ////Console.WriteLine(Mag1Copy.ToString());
- ///
- Magazine Mag1Copy = (Magazine)Mag1.DeepCopy();
- Mag1.name = "Magaz1";
- Mag1.Circulation = 1500;
- Console.WriteLine("////////////////Mag1////////////////////");
- Console.WriteLine(Mag1.ToString());
- Console.WriteLine("////////////////Mag1Copy////////////////////");
- Console.WriteLine(Mag1Copy.ToString());
- /////////////////////////////////////6
- foreach(Article art in Mag1.HighRateArticles(6))
- {
- //Console.WriteLine(art);
- }
- ////////////////////////7
- foreach(Article art in Mag1.StrInName("rt2"))
- {
- //Console.WriteLine(art);
- }
- }
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
Add Comment
Please, Sign In to add comment