JouJoy

Program.cs

Mar 26th, 2022 (edited)
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5.  
  6. namespace _15._03
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             //Magazine std = new Magazine();// преобразовываем данные объекта с помощью метода toshortString
  13.             //Console.WriteLine(std.ToShortString());
  14.             //Console.WriteLine();
  15.  
  16.             //foreach (Frequency element in Enum.GetValues(typeof(Frequency)))//вывожу значения индексатора для значений индекса
  17.             //    Console.WriteLine($"{element} = {std[element]}");
  18.             //Console.WriteLine();
  19.  
  20.             //std = new Magazine(new string("Glamur"), Frequency.Monthly, DateTime.MaxValue, 800);
  21.             //Console.WriteLine(std.ToShortString());//присваиваю значения свойствам Magazine  и вывожу с помощью метода ToString
  22.             //Console.WriteLine();
  23.  
  24.  
  25.             //std.AddArticles(
  26.             //new Article("\nVogue", 3.5, new Person("Ivanova")),//с помощбю метода addArticles добавляю элементы в список статей и вывожу
  27.             //new Article("\nElle", 7, new Person("Petrova")),
  28.             //new Article("\nSadovik", 10, new Person("Kuznetzova")),
  29.             //new Article("\nRussia", 20, new Person("Belova")));
  30.            
  31.             //Console.WriteLine(std.ToString());
  32.  
  33.  
  34.             //Stopwatch a1 = new Stopwatch();//сравниваю время выполнения операций с одинаковым числом элем типа Articles
  35.             //a1.Start();
  36.             //Article[] P1 = new Article[40000];
  37.             //for (int i = 0; i < P1.Length; i++)
  38.             //{
  39.             //    P1[i] = new Article();
  40.             //}
  41.             //a1.Stop();
  42.             //Console.WriteLine($"\nВремя первой операции: {a1.ElapsedMilliseconds}");
  43.  
  44.             //Stopwatch a2 = new Stopwatch();
  45.             //a2.Start();
  46.             //Article[,] P2 = new Article[400, 100];
  47.             //for (int i = 0; i < 400; i++)
  48.             //{
  49.             //    for (int j = 0; j < 100; j++)
  50.             //    {
  51.             //        P2[i, j] = new Article();
  52.             //    }
  53.             //}
  54.             //a2.Stop();
  55.             //Console.WriteLine($"\nВремя второй операции: {a2.ElapsedMilliseconds}");
  56.  
  57.             //Stopwatch a3 = new Stopwatch();
  58.             //a3.Start();
  59.             //Article[][] P3 = new Article[5][];
  60.             //{
  61.             //    for (int i = 0; i < 5; i++)
  62.             //    {
  63.             //        P3[i] = new Article[8000];
  64.             //        for (int j = 0; j < 8000; j++)
  65.             //        {
  66.             //            P3[i][j] = new Article();
  67.             //        }
  68.             //    }
  69.             //}
  70.             //a3.Stop();
  71.             //Console.WriteLine($"\nВремя третьей операции: {a3.ElapsedMilliseconds}");
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.             ////////////////////////////////////////////// вторая часть
  79.             //////////////////////1
  80.             Console.WriteLine("New part of task \r\n /////////////////////////////////////////////////////////\r\n");
  81.            
  82.             Edition Ed1 = new Edition("Name1", new DateTime(2022,03,01), 10);
  83.             Edition Ed2 = new Edition("Name1", new DateTime(2022,03,01), 10);
  84.             Console.WriteLine(Ed1.Equals(Ed2));
  85.             Console.WriteLine(Ed1 == Ed2);
  86.             Console.WriteLine(string.Format(" Edition1: {0}, Edition2: {1} ", Ed1.GetHashCode(), Ed2.GetHashCode()));
  87.             //////////////////////////////////////2
  88.            
  89.             try
  90.             {
  91.                 Ed2._Circulation = -10;
  92.             }
  93.             catch (ArgumentOutOfRangeException ex)
  94.             {
  95.                 Console.WriteLine(ex.Message);
  96.             }
  97.             ///////////////////////////////////////3
  98.             Magazine Mag1 = new Magazine("Magazine1", Frequency.Monthly, new DateTime(2000, 01, 01), 1000);
  99.             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")) });
  100.             Mag1.AddEditors(new Person[3] { new Person("Author of Art1"), new Person("Author of Art2"), new Person("Author of Art3") });
  101.             Console.WriteLine(Mag1.ToString());
  102.             /////////////////////////////4
  103.             Console.WriteLine(Mag1.GetEdition.ToString());
  104.             /////////////////////////////////5
  105.             ///если хочется проверить. что без дип копи данные меняются по ссылке во всех объектах, привязанных к ссылке
  106.             ////Magazine Mag1Copy = Mag1;
  107.             ////Mag1Copy.name = "Magazine234";
  108.             ////Console.WriteLine(Mag1.ToString());
  109.             ////Console.WriteLine(Mag1Copy.ToString());
  110.             ///
  111.             Magazine Mag1Copy = (Magazine)Mag1.DeepCopy();
  112.             Mag1.name = "Magaz1";
  113.             Mag1.Circulation = 1500;
  114.             Console.WriteLine("////////////////Mag1////////////////////");
  115.             Console.WriteLine(Mag1.ToString());
  116.             Console.WriteLine("////////////////Mag1Copy////////////////////");
  117.             Console.WriteLine(Mag1Copy.ToString());
  118.             /////////////////////////////////////6
  119.             foreach(Article art in Mag1.HighRateArticles(6))
  120.             {
  121.                 //Console.WriteLine(art);
  122.             }
  123.             ////////////////////////7
  124.             foreach(Article art in Mag1.StrInName("rt2"))
  125.             {
  126.                 //Console.WriteLine(art);
  127.             }
  128.         }
  129.  
  130.     }
  131.  
  132. }
  133. ///////////////////////////////////////////////////////////////////////////////////////////////////
  134.  
Add Comment
Please, Sign In to add comment