From 6d5e7b10c083f4e25db60c49537ef24f7deb7c76 Mon Sep 17 00:00:00 2001 From: shadowik Date: Mon, 19 Sep 2022 21:52:12 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20init=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80?= =?UTF-8?q?=D1=83=D0=BA=D1=82=D0=BE=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs | 7 ++----- DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs | 2 +- DoubleDeckerBus/DoubleDeckerBus/FormBus.cs | 4 +--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs index 1ec2432..06c6ed7 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/DrawningBus.cs @@ -18,7 +18,7 @@ namespace DoubleDeckerBus private readonly int _busWidth = 100; private readonly int _busHeight = 50; - public void Init(int speed, float weight, Color bodyColor) { + public DrawningBus(int speed, float weight, Color bodyColor) { Bus = new EntityBus(); Bus.Init(speed, weight, bodyColor); } @@ -74,23 +74,20 @@ namespace DoubleDeckerBus return; } Pen pen = new(Color.Black); - //границы автобсуса + g.DrawRectangle(pen, _startPosX - 1, _startPosY + 11, 100, 30); Brush brBodyColor = new SolidBrush(Bus.BodyColor); g.FillRectangle(brBodyColor, _startPosX, _startPosY + 10, 100, 30); - //Дверь g.DrawRectangle(pen, _startPosX + 30, _startPosY + 20, 10, 20); Brush brBlack = new SolidBrush(Color.Black); g.FillRectangle(brBlack, _startPosX + 30, _startPosY + 20, 10, 20); - //Колеса g.DrawEllipse(pen, _startPosX + 7, _startPosY + 35, 10, 10); g.DrawEllipse(pen, _startPosX + 77, _startPosY + 35, 10, 10); g.FillEllipse(brBlack, _startPosX + 7, _startPosY + 35, 10, 10); g.FillEllipse(brBlack, _startPosX + 77, _startPosY + 35, 10, 10); - //окна Brush brBlue = new SolidBrush(Color.Blue); g.FillEllipse(brBlue, _startPosX + 10, _startPosY + 15, 10, 15); g.FillEllipse(brBlue, _startPosX + 50, _startPosY + 15, 10, 15); diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs index 11c1050..45ee91a 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/EntityBus.cs @@ -12,7 +12,7 @@ namespace DoubleDeckerBus public float Weight { get; private set; } public Color BodyColor { get; private set; } public float Step => Speed * 100 / Weight; - public void Init(int speed, float weight, Color bodyColor) + public EntityBus(int speed, float weight, Color bodyColor) { Random rnd = new Random(); Speed = (speed <= 0) ? rnd.Next(50, 150) : speed; diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs index c4b4ce5..439fa64 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/FormBus.cs @@ -19,8 +19,7 @@ namespace DoubleDeckerBus private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _bus = new DrawningBus(); - _bus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + _bus = new DrawningBus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); _bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxBus.Width, pictureBoxBus.Height); toolStripStatusLabelSpeed.Text = $": {_bus.Bus.Speed}"; toolStripStatusLabelWeight.Text = $": {_bus.Bus.Weight}"; @@ -30,7 +29,6 @@ namespace DoubleDeckerBus private void ButtonMove_Click(object sender, EventArgs e) { - // string name = ((Button)sender)?.Name ?? string.Empty; switch (name) {