using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Diagnostics.CodeAnalysis; using DoubleDeckerbus.Drawing; using DoubleDeckerbus.Entities; namespace DoubleDeckerbus.Generics { internal class DrawingBusEqutables : IEqualityComparer { public bool Equals(DrawingBus? x, DrawingBus? y) { if (x == null && x.EntityBus == null) throw new ArgumentNullException(nameof(x)); if (y == null && y.EntityBus == null) throw new ArgumentNullException(nameof(y)); if ((x.GetType().Name != y.GetType().Name)) return false; if (x.EntityBus.Speed != y.EntityBus.Speed) return false; if (x.EntityBus.Weight != y.EntityBus.Weight) return false; if (x.EntityBus.BodyColor != y.EntityBus.BodyColor) return false; if (x is DrawingDoubleDeckerbus && y is DrawingDoubleDeckerbus) { var xDoublebus = (EntityDoubleDeckerbus)x.EntityBus; var yDoublebus = (EntityDoubleDeckerbus)y.EntityBus; if (xDoublebus.AddColor != yDoublebus.AddColor) return false; if (xDoublebus.IsSecondFloor != yDoublebus.IsSecondFloor) return false; if (xDoublebus.IsStairs != yDoublebus.IsStairs) return false; } return true; } public int GetHashCode([DisallowNull] DrawingBus? obj) { return obj.GetHashCode(); } } }