From 75e3a5d82363ed163309ad871cd25c69b2fd7b43 Mon Sep 17 00:00:00 2001 From: Daniya_Youdakova Date: Sun, 25 Dec 2022 17:20:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=B0=D0=B1-7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AircraftCarrier/AircraftCarrier/DrawningAircraftCarrier.cs | 4 ++-- .../AircraftCarrier/DrawningObjectAircraftCarrier.cs | 3 +-- AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs | 6 ------ 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/AircraftCarrier/AircraftCarrier/DrawningAircraftCarrier.cs b/AircraftCarrier/AircraftCarrier/DrawningAircraftCarrier.cs index 4306f0a..44200af 100644 --- a/AircraftCarrier/AircraftCarrier/DrawningAircraftCarrier.cs +++ b/AircraftCarrier/AircraftCarrier/DrawningAircraftCarrier.cs @@ -52,6 +52,7 @@ namespace AircraftCarrier { _startPosX = x; _startPosY = y; + _pictureWidth = width; _pictureHeigth = height; } @@ -126,17 +127,16 @@ namespace AircraftCarrier { _startPosX = _pictureWidth.Value - _aircraftcarrierWidth; } + if (_startPosY + _aircraftcarrierHeight > _pictureHeigth) { _startPosY = _pictureHeigth.Value - _aircraftcarrierHeight; } } - public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() { return (_startPosX, _startPosY, _startPosX + _aircraftcarrierWidth, _startPosY + _aircraftcarrierHeight); } - public void ReturnColor(Color returnColor) { if (AircraftCarrier is not EntityModernAircraftCarrier modernAircraftCarrier) diff --git a/AircraftCarrier/AircraftCarrier/DrawningObjectAircraftCarrier.cs b/AircraftCarrier/AircraftCarrier/DrawningObjectAircraftCarrier.cs index e28ee81..f780fdc 100644 --- a/AircraftCarrier/AircraftCarrier/DrawningObjectAircraftCarrier.cs +++ b/AircraftCarrier/AircraftCarrier/DrawningObjectAircraftCarrier.cs @@ -30,8 +30,7 @@ namespace AircraftCarrier { _aircraftcarrier.DrawTransport(g); } - public string GetInfo() => _aircraftcarrier?.AircraftCarrier.ToString(); - + public string GetInfo() => _aircraftcarrier?.GetDataForSave(); public static IDrawningObject Create(string data) => new DrawningObjectAircraftCarrier(data.CreateDrawningAircraftCarrier()); } } \ No newline at end of file diff --git a/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs b/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs index 76f978a..b6dbf8c 100644 --- a/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs +++ b/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs @@ -8,7 +8,6 @@ namespace AircraftCarrier { public class EntityAircraftCarrier { - private static readonly char _separatorForObject = ':'; public int Speed { get; private set; } public float Weight { get; private set; } public Color BodyColor { get; set; } @@ -20,10 +19,5 @@ namespace AircraftCarrier Weight = weight <= 0 ? rnd.Next(40, 70) : weight; BodyColor = bodyColor; } - public override string ToString() - { - var str = $"{Speed}{_separatorForObject}{Weight}{_separatorForObject}{BodyColor.Name}"; - return str; - } } } \ No newline at end of file