From 993e92ab6cfca9ca8ecee80d19c6acae5a4a7431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 21 Sep 2022 00:19:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=E2=84=961.=20=D0=9D?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B5=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B5=D0=BF=D0=BE=D0=B4=D0=B0=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs index b8d7f9f..b942956 100644 --- a/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawingWarmlyShip.cs @@ -24,8 +24,9 @@ namespace WarmlyShip public void SetPosition(int x, int y, int width, int height) { - _startPosX = x; - _startPosY = y; + Random random = new Random(); + _startPosX = x < 0 || x > width ? random.Next(0, width) : x; + _startPosY = y < 0 || y > height ? random.Next(0, height) : y; _pictureWidth = width; _pictureHeight = height; }