From fbef71ec0b778920676fdc2bc87336c24b891e3d Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Mon, 31 Oct 2022 20:34:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArmoredCar/ArmoredCar/DrawningArmoredCar.cs | 6 ++---- ArmoredCar/ArmoredCar/DrawningTank.cs | 10 +++++++--- ArmoredCar/ArmoredCar/EntityArmoredCar.cs | 2 -- ArmoredCar/ArmoredCar/EntityTank.cs | 2 -- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ArmoredCar/ArmoredCar/DrawningArmoredCar.cs b/ArmoredCar/ArmoredCar/DrawningArmoredCar.cs index 039c944..7b5ec60 100644 --- a/ArmoredCar/ArmoredCar/DrawningArmoredCar.cs +++ b/ArmoredCar/ArmoredCar/DrawningArmoredCar.cs @@ -178,10 +178,8 @@ namespace ArmoredCar return (_startPosX, _startPosX + _carWidth, _startPosY, _startPosY + _carHeight); } - public void setColor(Color color) { - if (ArmoredCar == null) - return; - ArmoredCar.setColor(color); + public virtual void setColor(Color color) { + ArmoredCar = new EntityArmoredCar(ArmoredCar.Speed, ArmoredCar.Weight, color); } } } diff --git a/ArmoredCar/ArmoredCar/DrawningTank.cs b/ArmoredCar/ArmoredCar/DrawningTank.cs index effba00..b842464 100644 --- a/ArmoredCar/ArmoredCar/DrawningTank.cs +++ b/ArmoredCar/ArmoredCar/DrawningTank.cs @@ -47,11 +47,15 @@ namespace ArmoredCar base.DrawTransport(g); _startPosY -= 10; } + public override void setColor(Color color) + { + ArmoredCar = new EntityTank(ArmoredCar.Speed, ArmoredCar.Weight, color, + (ArmoredCar as EntityTank).DopColor, (ArmoredCar as EntityTank).TowerWeapon, (ArmoredCar as EntityTank).AMachineGun); + } public void setDopColor(Color color) { - if (ArmoredCar is not EntityTank Tank) - return; - Tank.setDopColor(color); + ArmoredCar = new EntityTank(ArmoredCar.Speed, ArmoredCar.Weight, ArmoredCar.BodyColor, + color, (ArmoredCar as EntityTank).TowerWeapon, (ArmoredCar as EntityTank).AMachineGun); } } } diff --git a/ArmoredCar/ArmoredCar/EntityArmoredCar.cs b/ArmoredCar/ArmoredCar/EntityArmoredCar.cs index 3566a34..bf04efc 100644 --- a/ArmoredCar/ArmoredCar/EntityArmoredCar.cs +++ b/ArmoredCar/ArmoredCar/EntityArmoredCar.cs @@ -37,7 +37,5 @@ namespace ArmoredCar Weight = weight <= 0 ? rnd.Next(40, 70) : weight; BodyColor = bodyColor; } - - public virtual void setColor(Color color) { BodyColor = color; } } } diff --git a/ArmoredCar/ArmoredCar/EntityTank.cs b/ArmoredCar/ArmoredCar/EntityTank.cs index cca7487..e540189 100644 --- a/ArmoredCar/ArmoredCar/EntityTank.cs +++ b/ArmoredCar/ArmoredCar/EntityTank.cs @@ -39,7 +39,5 @@ namespace ArmoredCar TowerWeapon = towerWeapon; AMachineGun = aMachineGun; } - - public void setDopColor(Color dopColor){DopColor = dopColor;} } }