diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs index c85dc44..3ccc120 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs @@ -60,9 +60,9 @@ namespace ProjectLiner.CollectionGenericObjects /// Компания /// Добавляемый объект /// - 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() ); } /// diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningLinerCompareByType.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningLinerCompareByType.cs new file mode 100644 index 0000000..55584e5 --- /dev/null +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningLinerCompareByType.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.Drawnings; +/// +/// Сравнение по типу, скорости, весу +/// +public class DrawningLinerCompareByType : IComparer +{ + + 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); + } +}