BeloMaximka

Belov_LW_CS3

Feb 8th, 2022 (edited)
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. namespace Classwork
  2. {
  3.     class Journal
  4.     {
  5.         public string Name { get; set; }
  6.         public int FoundationYear { get; set; }
  7.         public string Describtion { get; set; }
  8.         public string Email { get; set; }
  9.  
  10.         int employeesCount;
  11.         public int EmployeesCount
  12.         {
  13.             get => employeesCount;
  14.             set
  15.             {
  16.                 employeesCount = value >= 0 ? value : 0;
  17.             }
  18.         }
  19.         public Journal(string name, int year, string desc, string emal)
  20.         {
  21.             Name = name;
  22.             FoundationYear = year;
  23.             Describtion = desc;
  24.             Email = emal;
  25.         }
  26.         public override string ToString()
  27.         {
  28.             return $"Name - {Name}\nYear of foundation - {FoundationYear}\nDescribtion - {Describtion}\nEmail - {Email}";
  29.         }
  30.  
  31.         public static Journal operator +(Journal journal, int value)
  32.         {
  33.             Journal result = (Journal)journal.MemberwiseClone();
  34.             result.EmployeesCount += value;
  35.             return result;
  36.         }
  37.         public static Journal operator -(Journal journal, int value)
  38.         {
  39.             Journal result = (Journal)journal.MemberwiseClone();
  40.             result.EmployeesCount -= value;
  41.             result.EmployeesCount = result.EmployeesCount >= 0 ? result.EmployeesCount : 0;
  42.             return result;
  43.         }
  44.         public static bool operator ==(Journal journal, int value)
  45.         {
  46.             return journal.EmployeesCount == value;
  47.         }
  48.         public static bool operator !=(Journal journal, int value)
  49.         {
  50.             return journal.EmployeesCount != value;
  51.         }
  52.         public static bool operator >(Journal journal, int value)
  53.         {
  54.             return journal.EmployeesCount > value;
  55.         }
  56.         public static bool operator <(Journal journal, int value)
  57.         {
  58.             return journal.EmployeesCount < value;
  59.         }
  60.     }
  61. }
Add Comment
Please, Sign In to add comment