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;} } }