4DM3M

13

Jan 3rd, 2022
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Drafty
  5. {
  6.     class Program
  7.     {
  8.         interface CallCenter
  9.         {
  10.             public void Response();
  11.  
  12.             public void Call();
  13.         }
  14.  
  15.         class Corp1 : CallCenter
  16.         {
  17.             string[] workersName;
  18.  
  19.             public Corp1(params string[] workersName)
  20.             {
  21.                 if (workersName.Length == 0)
  22.                 {
  23.                     this.workersName = new string[1] { "Юлия" };
  24.                 }
  25.                 else
  26.                 {
  27.                     this.workersName = new string[workersName.Length];
  28.  
  29.                     for (int i=0; i<workersName.Length; i++)
  30.                     {
  31.                         this.workersName[i] = workersName[i];
  32.                     }
  33.                 }
  34.  
  35.             }
  36.            
  37.             public void Call()
  38.             {
  39.                 Console.WriteLine("Здравствуйте, где вы живёте?");
  40.             }
  41.  
  42.             public void Response()
  43.             {
  44.                 Random random = new();
  45.                 Console.WriteLine($"Здравствуйте, {this.workersName[random.Next(0, this.workersName.Length - 1)]} вас слушает");
  46.             }
  47.         }
  48.  
  49.         class Corp2 : CallCenter
  50.         {
  51.             public void Call()
  52.             {
  53.                 Console.WriteLine("Зачем вы сюда звОните?");
  54.             }
  55.  
  56.             public void Response()
  57.             {
  58.                 Console.WriteLine("Не звоните сюда больше");
  59.             }
  60.         }
  61.  
  62.         static void Main(string[] args)
  63.         {
  64.             CallCenter someCorp = new Corp2();
  65.             CallCenter anotherCorp = new Corp1("Антон", "Евгений", "Елена");
  66.  
  67.             someCorp.Call();
  68.             someCorp.Response();
  69.             Console.WriteLine();
  70.  
  71.             anotherCorp.Call();
  72.             anotherCorp.Response();
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment