+ class compareByColor and method 'Sort'
This commit is contained in:
parent
8fab9e1bb6
commit
ae63529594
@ -1,4 +1,5 @@
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
using ProjectElectricLocomotive.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -11,9 +12,21 @@ namespace ProjectElectricLocomotive
|
||||
{
|
||||
public int Compare(DrawingLocomotive? x, DrawingLocomotive? y)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
|
||||
if (x == null || x.EntityLocomotive == null)
|
||||
throw new NotImplementedException(nameof(x));
|
||||
if (y == null || y.EntityLocomotive == null)
|
||||
throw new NotImplementedException(nameof(y));
|
||||
var bodyColor = x.EntityLocomotive.BodyColor.Name.CompareTo(y.EntityLocomotive.BodyColor.Name);
|
||||
if (bodyColor != 0) return bodyColor;
|
||||
if(x.EntityLocomotive is EntityElectricLocomotive xEntityElectricLocomotive &&
|
||||
y.EntityLocomotive is EntityElectricLocomotive yEntityElectricLocomotive)
|
||||
{
|
||||
var addcolor = (x.EntityLocomotive as EntityElectricLocomotive).AdditionalColor.Name.CompareTo(
|
||||
(y.EntityLocomotive as EntityElectricLocomotive).AdditionalColor.Name);
|
||||
if(addcolor != 0) return addcolor;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ namespace ProjectElectricLocomotive.Generics
|
||||
/// </summary>
|
||||
public IEnumerable<T?> GetLocomotives => _collection.GetLocomotives();
|
||||
|
||||
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
|
||||
|
||||
|
||||
//ширина/высота окна
|
||||
private readonly int _pictureWidth;
|
||||
|
@ -16,6 +16,9 @@ namespace ProjectElectricLocomotive.Generics
|
||||
|
||||
/// Максимальное количество объектов в списке
|
||||
private readonly int _maxCount;
|
||||
|
||||
public void SortSet(IComparer<T?> comparer) =>_places.Sort(comparer);
|
||||
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
|
Loading…
Reference in New Issue
Block a user