66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
|
using Airbus_Base.DrawningObjects;
|
|||
|
using Airbus_Base.Entities;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Diagnostics.CodeAnalysis;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Airbus_Base.Generics
|
|||
|
{
|
|||
|
internal class DrawiningAirplaneEqutables : IEqualityComparer<DrawningAirplane?>
|
|||
|
{
|
|||
|
public bool Equals(DrawningAirplane? x, DrawningAirplane? y)
|
|||
|
{
|
|||
|
if (x == null || x.EntityAirplane == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(x));
|
|||
|
}
|
|||
|
if (y == null || y.EntityAirplane == null)
|
|||
|
{
|
|||
|
throw new ArgumentNullException(nameof(y));
|
|||
|
}
|
|||
|
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 DrawningAirbus && y is DrawningAirbus)
|
|||
|
{
|
|||
|
EntityAirbus EntityX = (EntityAirbus)x.EntityAirplane;
|
|||
|
EntityAirbus EntityY = (EntityAirbus)y.EntityAirplane;
|
|||
|
if (EntityX.AdditionalPassengerCompartment != EntityY.AdditionalPassengerCompartment)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (EntityX.AdditionalEngine != EntityY.AdditionalEngine)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (EntityX.AdditionalColor != EntityY.AdditionalColor)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public int GetHashCode([DisallowNull] DrawningAirplane? obj)
|
|||
|
{
|
|||
|
return obj.GetHashCode();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|