Лаба№1. Не проверена преподавателем.

This commit is contained in:
Макс Бондаренко 2022-09-21 00:19:27 +04:00
parent fb90f09de8
commit 993e92ab6c

View File

@ -24,8 +24,9 @@ namespace WarmlyShip
public void SetPosition(int x, int y, int width, int height) public void SetPosition(int x, int y, int width, int height)
{ {
_startPosX = x; Random random = new Random();
_startPosY = y; _startPosX = x < 0 || x > width ? random.Next(0, width) : x;
_startPosY = y < 0 || y > height ? random.Next(0, height) : y;
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
} }