using System.Diagnostics.CodeAnalysis; namespace ElectricLocomotive; public class DrawingLocomotivEqutables: IEqualityComparer { public bool Equals(DrawingLocomotiv? x, DrawingLocomotiv? y) { if (x == null || x.EntityLocomotiv == null) { throw new ArgumentNullException(nameof(x)); } if (y == null || y.EntityLocomotiv == null) { throw new ArgumentNullException(nameof(y)); } if (x.GetType().Name != y.GetType().Name) { return false; } if (x.EntityLocomotiv.Speed != y.EntityLocomotiv.Speed) { return false; } if (x.EntityLocomotiv.Weight != y.EntityLocomotiv.Weight) { return false; } if (x.EntityLocomotiv.ColorBody != y.EntityLocomotiv.ColorBody) { return false; } if (x is DrawingElectricLocomotiv && y is DrawingElectricLocomotiv) { EntityElectricLocomotiv EntityX = (EntityElectricLocomotiv)x.EntityLocomotiv; EntityElectricLocomotiv EntityY = (EntityElectricLocomotiv)y.EntityLocomotiv; if (EntityX.isBattery != EntityY.isBattery) return false; if (EntityX.isRoga != EntityY.isRoga) return false; } return true; } public int GetHashCode([DisallowNull] DrawingLocomotiv obj) { return obj.GetHashCode(); } }