From 17895a1d639420c6b1bff2f7d82fd80214e5b73b Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Fri, 22 Dec 2023 21:31:06 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=208?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank/TankCompareByColor.cs | 5 +++++ Tank/Tank/TanksCollectionInfo.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Tank/Tank/TankCompareByColor.cs b/Tank/Tank/TankCompareByColor.cs index 9515d36..895cf85 100644 --- a/Tank/Tank/TankCompareByColor.cs +++ b/Tank/Tank/TankCompareByColor.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tank.DrawningObjects; +using Tank.Entities; namespace Tank { @@ -23,6 +24,10 @@ namespace Tank { return x.Tank.BodyColor.Name.CompareTo(y.Tank.BodyColor.Name); } + if (x.GetType() == y.GetType() && x is DrawTank) + { + return (x.Tank as EntityTank).AdditionalColor.Name.CompareTo((y.Tank as EntityTank).AdditionalColor.Name); + } var speedCompare = x.Tank.Speed.CompareTo(y.Tank.Speed); if (speedCompare != 0) { diff --git a/Tank/Tank/TanksCollectionInfo.cs b/Tank/Tank/TanksCollectionInfo.cs index feb68e7..529d7d5 100644 --- a/Tank/Tank/TanksCollectionInfo.cs +++ b/Tank/Tank/TanksCollectionInfo.cs @@ -20,7 +20,7 @@ namespace Tank public bool Equals(TankCollectionInfo? other) { if (other == null || Name == null || other.Name == null) return false; - if (Name == other.Name) return true; + if (Name == other?.Name) return true; throw new NotImplementedException(); }