using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectAirplaneWithRadar.Entities;
namespace ProjectAirplaneWithRadar.Drawnings
{
///
/// Реализация сравнения двух объектов класса-прорисовки
///
public class DrawningAirplaneEqutables : IEqualityComparer
{
public bool Equals(DrawningAirplane? x, DrawningAirplane? y)
{
if (x == null || x.EntityAirplane == null)
{
return false;
}
if (y == null || y.EntityAirplane == null)
{
return false;
}
if (x.GetType().Name != y.GetType().Name)
{
return false;
}
if (x.EntityAirplane.Speed != y.EntityAirplane.Speed)
{
return false;
}
if (x.EntityAirplane.Weight != y.EntityAirplane.Weight)
{
return false;
}
if (x.EntityAirplane.BodyColor != y.EntityAirplane.BodyColor)
{
return false;
}
if (x is DrawingAirplaneWithRadar && y is DrawingAirplaneWithRadar)
{
EntityAirplaneWithRadar entityX = (EntityAirplaneWithRadar)x.EntityAirplane;
EntityAirplaneWithRadar entityY = (EntityAirplaneWithRadar)y.EntityAirplane;
if (entityX.AdditionalColor != entityY.AdditionalColor)
{
return false;
}
if (entityX.Wheels != entityY.Wheels)
{
return false;
}
if (entityX.Radar != entityY.Radar)
{
return false;
}
}
return true;
}
public int GetHashCode([DisallowNull] DrawningAirplane obj)
{
return obj.GetHashCode();
}
}
}