С дополнительным первым заданием

This commit is contained in:
gettterot 2024-02-21 16:54:00 +04:00
parent 997c87a792
commit bd746e9288
2 changed files with 10 additions and 6 deletions

View File

@ -50,10 +50,9 @@ public class DrawningLiner
/// <param name="anchor">Признак наличия якоря</param> /// <param name="anchor">Признак наличия якоря</param>
/// <param name="boats">Признак наличия шлюпок</param> /// <param name="boats">Признак наличия шлюпок</param>
/// <param name="pipe">Признак наличия трубы</param> /// <param name="pipe">Признак наличия трубы</param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool anchor, bool boats, bool pipe) public void Init(EntityLiner liner)
{ {
EntityLiner = new EntityLiner(); EntityLiner = liner;
EntityLiner.Init(speed, weight, bodyColor, additionalColor, anchor, boats, pipe);
_pictureWidth = null; _pictureWidth = null;
_pictureHeight = null; _pictureHeight = null;
_startPosX = null; _startPosX = null;
@ -108,7 +107,10 @@ public class DrawningLiner
{ {
_startPosX = x; _startPosX = x;
_startPosY = y; _startPosY = y;
if (_startPosX.Value < 0)
_startPosX = 0;
if (_startPosY.Value < 0)
_startPosY = 0;
if (_startPosX.Value + _drawningLinerWidth > _pictureWidth) if (_startPosX.Value + _drawningLinerWidth > _pictureWidth)
{ {
_startPosX = _pictureWidth - _drawningLinerWidth; _startPosX = _pictureWidth - _drawningLinerWidth;

View File

@ -42,11 +42,13 @@ namespace ProjectLiner
private void buttonCreate_Click(object sender, EventArgs e) private void buttonCreate_Click(object sender, EventArgs e)
{ {
Random random = new(); Random random = new();
_drawningLiner = new DrawningLiner(); EntityLiner liner = new EntityLiner();
_drawningLiner.Init(random.Next(100, 300), random.Next(1000, 3000), liner.Init(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_drawningLiner = new DrawningLiner();
_drawningLiner.Init(liner);
_drawningLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); _drawningLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height);
_drawningLiner.SetPosition(random.Next(10, 100), random.Next(10, 100)); _drawningLiner.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw(); Draw();