From 13de54b639e9c3bd4a6724eea56c754554064fd4 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 20:22:15 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20DrawingPlaneEqutables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawingPlaneEqutables.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 ProjectStormtrooper/ProjectStormtrooper/DrawingPlaneEqutables.cs diff --git a/ProjectStormtrooper/ProjectStormtrooper/DrawingPlaneEqutables.cs b/ProjectStormtrooper/ProjectStormtrooper/DrawingPlaneEqutables.cs new file mode 100644 index 0000000..9c93c03 --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/DrawingPlaneEqutables.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectStormtrooper +{ + public class DrawingPlaneEqutables : IEqualityComparer + { + public bool Equals(DrawingPlane? x, DrawingPlane? y) + { + if (x == null || x.EntityPlane == null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y == null || y.EntityPlane == null) + { + throw new ArgumentNullException(nameof(y)); + } + if (x.GetType().Name != y.GetType().Name) + { + return false; + } + if (x.EntityPlane.Speed != y.EntityPlane.Speed) + { + return false; + } + if (x.EntityPlane.Weight != y.EntityPlane.Weight) + { + return false; + } + if (x.EntityPlane.BodyColor != y.EntityPlane.BodyColor) + { + return false; + } + if (x is DrawingStormtrooper && y is DrawingStormtrooper) + { + var xStormtrooper = (x.EntityPlane as EntityStormtrooper); + var yStormtrooper = (y.EntityPlane as EntityStormtrooper); + if (xStormtrooper?.AdditionalColor != yStormtrooper?.AdditionalColor) + { + return false; + } + if (xStormtrooper?.Bombs != yStormtrooper?.Bombs) + { + return false; + } + if (xStormtrooper?.Rockets != yStormtrooper?.Rockets) + { + return false; + } + } + return true; + } + + public int GetHashCode([DisallowNull] DrawingPlane obj) + { + return obj.GetHashCode(); + } + } +}