Добавлены классы PlaneCompare
This commit is contained in:
parent
adbf68e639
commit
85829c9c39
ProjectStormtrooper/ProjectStormtrooper
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper
|
||||
{
|
||||
public class PlaneCompareByColor : IComparer<DrawingPlane?>
|
||||
{
|
||||
public int Compare(DrawingPlane? x, DrawingPlane? y)
|
||||
{
|
||||
if (x == null || x.EntityPlane == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
if (y == null || y.EntityPlane == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
if (x.EntityPlane.BodyColor != y.EntityPlane.BodyColor)
|
||||
{
|
||||
return x.EntityPlane.BodyColor.Name.CompareTo(y.EntityPlane.BodyColor.Name);
|
||||
}
|
||||
var speedCompare = x.EntityPlane.Speed.CompareTo(y.EntityPlane.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return x.EntityPlane.Weight.CompareTo(y.EntityPlane.Weight);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper
|
||||
{
|
||||
public class PlaneCompareByType : IComparer<DrawingPlane?>
|
||||
{
|
||||
public int Compare(DrawingPlane? x, DrawingPlane? y)
|
||||
{
|
||||
if (x == null || x.EntityPlane == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
if (y == null || y.EntityPlane == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||
}
|
||||
var speedCompare = x.EntityPlane.Speed.CompareTo(y.EntityPlane.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return x.EntityPlane.Weight.CompareTo(y.EntityPlane.Weight);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user