ISEbd-22. Baygulov A.A. Lab work 08 #9

Closed
tellsense wants to merge 4 commits from lab8 into lab7
Showing only changes of commit d0842fc00e - Show all commits

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectElectricLocomotive.DrawingObjects;
using ProjectElectricLocomotive.Entities;
using System.Diagnostics.CodeAnalysis;
namespace ProjectElectricLocomotive.Generics
{
internal class DrawingLocomotiveEqutables : IEqualityComparer<DrawingLocomotive?>
{
public bool Equals(DrawingLocomotive? x, DrawingLocomotive? y)
{
if (x == null || x.EntityLocomotive == null)
{
throw new ArgumentNullException(nameof(x));
}
if (y == null || y.EntityLocomotive == null)
{
throw new ArgumentNullException(nameof(y));
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityLocomotive.Speed != y.EntityLocomotive.Speed)
{
return false;
}
if (x.EntityLocomotive.Weight != y.EntityLocomotive.Weight)
{
return false;
}
if (x.EntityLocomotive.BodyColor != y.EntityLocomotive.BodyColor)
{
return false;
}
if (x is DrawingElectricLocomotive && y is DrawingElectricLocomotive)
{
// TODO доделать логику сравнения дополнительных параметров
}
return true;
}
public int GetHashCode([DisallowNull] DrawingLocomotive obj)
{
return obj.GetHashCode();
}
}
}