Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Classwork
- {
- class Journal
- {
- public string Name { get; set; }
- public int FoundationYear { get; set; }
- public string Describtion { get; set; }
- public string Email { get; set; }
- int employeesCount;
- public int EmployeesCount
- {
- get => employeesCount;
- set
- {
- employeesCount = value >= 0 ? value : 0;
- }
- }
- public Journal(string name, int year, string desc, string emal)
- {
- Name = name;
- FoundationYear = year;
- Describtion = desc;
- Email = emal;
- }
- public override string ToString()
- {
- return $"Name - {Name}\nYear of foundation - {FoundationYear}\nDescribtion - {Describtion}\nEmail - {Email}";
- }
- public static Journal operator +(Journal journal, int value)
- {
- Journal result = (Journal)journal.MemberwiseClone();
- result.EmployeesCount += value;
- return result;
- }
- public static Journal operator -(Journal journal, int value)
- {
- Journal result = (Journal)journal.MemberwiseClone();
- result.EmployeesCount -= value;
- result.EmployeesCount = result.EmployeesCount >= 0 ? result.EmployeesCount : 0;
- return result;
- }
- public static bool operator ==(Journal journal, int value)
- {
- return journal.EmployeesCount == value;
- }
- public static bool operator !=(Journal journal, int value)
- {
- return journal.EmployeesCount != value;
- }
- public static bool operator >(Journal journal, int value)
- {
- return journal.EmployeesCount > value;
- }
- public static bool operator <(Journal journal, int value)
- {
- return journal.EmployeesCount < value;
- }
- }
- }
Add Comment
Please, Sign In to add comment