From 4fe6f533bf3f0d27c2f7066ad15c0bb06fd4bde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BE=D0=BB=D0=BE=D0=B4=D1=8F?= Date: Mon, 26 Sep 2022 08:45:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirPlaneWithRadar/DrawingPlain.cs | 24 +++++++++++++------ .../AirPlaneWithRadar/EntetyPlain.cs | 11 +++++---- .../AirPlaneWithRadar/FormPlain.cs | 4 ++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/DrawingPlain.cs b/AirPlaneWithRadar/AirPlaneWithRadar/DrawingPlain.cs index 90f15b4..0b0acdd 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/DrawingPlain.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/DrawingPlain.cs @@ -16,11 +16,11 @@ namespace AirPlaneWithRadar private int? pictureHeight = null; protected readonly int plainWidth = 120; protected readonly int plainHeight =70; - public void Init (int speed, float weight, Color bodycolor) + public DrawingPlain(int speed, float weight, Color bodycolor) { - Plain = new EntetyPlain (); - Plain.Init (speed, weight, bodycolor); + Plain = new EntetyPlain(speed, weight, bodycolor); } + public void setPosition(int x,int y,int width,int height) { if (x + plainWidth > width || y + plainHeight > height || plainHeight > height || plainWidth > width || x <0 || y<0) @@ -66,27 +66,37 @@ namespace AirPlaneWithRadar } Pen pen = new Pen(Color.Black); - + + g.DrawRectangle(pen, startPosX, startPosY, 20, 30); g.DrawRectangle(pen, startPosX, startPosY + 30, 100, 30); g.DrawRectangle(pen, startPosX+100, startPosY + 40, 20, 15); - + //koleso1 g.DrawRectangle(pen, startPosX + 30, startPosY + 60, 5, 10); g.DrawEllipse(pen, startPosX+28, startPosY+70, 9, 9); - + //koleso2 g.DrawRectangle(pen, startPosX + 80, startPosY + 60, 5, 10); g.DrawEllipse(pen, startPosX + 78, startPosY + 70, 9, 9); - + + //Korpys Brush br = new SolidBrush(Plain?.BodyColor ?? Color.Black); g.FillRectangle(br, startPosX+3, startPosY + 33, 94, 24); g.FillRectangle(br, startPosX+1, startPosY+1, 19, 29); + + //krilya Brush brWings = new SolidBrush(Color.Black); g.FillRectangle(brWings, startPosX + 30, startPosY + 40, 40, 8); + + //cabina Brush brCabine = new SolidBrush(Color.Blue); g.FillRectangle(brCabine, startPosX + 101, startPosY + 41, 19, 14); + + + + } public void ChangeBorders(int width, int height) diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/EntetyPlain.cs b/AirPlaneWithRadar/AirPlaneWithRadar/EntetyPlain.cs index 1694c17..48af56c 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/EntetyPlain.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/EntetyPlain.cs @@ -14,13 +14,14 @@ namespace AirPlaneWithRadar public Color BodyColor { get; private set; } public float Step => Speed * 100 / Weight; - public void Init (int speed, float weight, Color bodycolor) + public EntetyPlain(int speed, float weight, Color bodyColor) { Random rd = new Random(); - - Speed = speed <= 0 ? rd.Next(50,150):speed; - Weight = weight <= 0 ? rd.Next(40, 70) :weight; - BodyColor = bodycolor; + Speed = speed <= 0 ? rd.Next(50, 150) : speed; + Weight = weight <= 0 ? rd.Next(40, 70) : weight; + BodyColor = bodyColor; } + + } } diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs b/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs index 52158d0..25cdcc4 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/FormPlain.cs @@ -22,9 +22,9 @@ namespace AirPlaneWithRadar private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _plain = new DrawingPlain(); + _plain = new DrawingPlain(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - _plain.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _plain.setPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxPlain.Width, pictureBoxPlain.Height); toolStripStatusLabelSpeed.Text = $"Скорость: {_plain.Plain.Speed}"; toolStripStatusLabelWeight.Text = $"Вес: {_plain.Plain.Weight}";