Advertisement
AskTomorrow

Untitled

Feb 16th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Task_1
  8. {
  9.     class Program
  10.     {
  11.         public static Random rnd = new Random();
  12.         static void Main(string[] args)
  13.         {
  14.             do
  15.             {
  16.                 Phone[] phones = new Phone[100];
  17.  
  18.                 for (int i = 0; i < phones.Length; i++)
  19.                 {
  20.                     phones[i] = new Phone(rnd.Next(100, 401));
  21.                 }
  22.  
  23.                 for (int i = 0; i < phones.Length; i++)
  24.                 {
  25.                     for (int j = 0; j < 20; j++)
  26.                     {
  27.                         if (rnd.Next(100, 401) != phones[i].Number)
  28.                         {
  29.                             phones[i].AddPhoneToBook(new Phone(rnd.Next(100, 401)));
  30.                         }
  31.                         else
  32.                         {
  33.                             phones[i].AddPhoneToBook(new Phone(rnd.Next(100, 401) + 1));
  34.                         }
  35.                     }
  36.                     //phones[i].OnCall += ((int CallerNumber) => Console.WriteLine($"На телефон {phones[i].Number} был совершен звонок с номера {CallerNumber}"));
  37.                 }
  38.  
  39.                 for (int i = 0; i < phones.Length; i++)
  40.                 {
  41.                     phones[i].Call(rnd.Next(100, 401));
  42.                 }
  43.  
  44.  
  45.                 Console.WriteLine("Press any key to continue. Press esc to exit");
  46.             } while (Console.ReadKey().Key != ConsoleKey.Escape);
  47.         }
  48.  
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement