Добавили DrawningLinerCompareByType

This commit is contained in:
gettterot 2024-06-10 05:54:10 +04:00
parent 859a9ffff6
commit 5c7b6d8bf2
2 changed files with 42 additions and 2 deletions

View File

@ -60,9 +60,9 @@ namespace ProjectLiner.CollectionGenericObjects
/// <param name="company">Компания</param>
/// <param name="airplane">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningCommonLiner airplane)
public static int operator +(AbstractCompany company, DrawningCommonLiner liner)
{
return company._collection.Insert(airplane);
return company._collection.Insert(liner, new DrawningLinerEqutables() );
}
/// <summary>

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLiner.Drawnings;
/// <summary>
/// Сравнение по типу, скорости, весу
/// </summary>
public class DrawningLinerCompareByType : IComparer<DrawningCommonLiner?>
{
public int Compare(DrawningCommonLiner? x, DrawningCommonLiner? y)
{
if (x == null && y == null) return 0;
if (x == null || x.EntityCommonLiner == null)
{
return 1;
}
if (y == null || y.EntityCommonLiner == null)
{
return -1;
}
if (x.GetType().Name != y.GetType().Name)
{
return x.GetType().Name.CompareTo(y.GetType().Name);
}
var speedCompare = x.EntityCommonLiner.Speed.CompareTo(y.EntityCommonLiner.Speed);
if (speedCompare != 0)
{
return speedCompare;
}
return x.EntityCommonLiner.Weight.CompareTo(y.EntityCommonLiner.Weight);
}
}