diff --git a/AccordionBus/AccordionBus/DrawningAccordionBus.cs b/AccordionBus/AccordionBus/DrawningAccordionBus.cs
deleted file mode 100644
index 019b102..0000000
--- a/AccordionBus/AccordionBus/DrawningAccordionBus.cs
+++ /dev/null
@@ -1,202 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing.Drawing2D;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace AccordionBus;
-public class DrawningAccordionBus
-{
- ///
- /// Класс-сущность
- ///
- public EntityAccordionBus? EntityAccordionBus { get; private set; }
- ///
- /// Ширина окна
- ///
- private int? _pictureWidth;
- ///
- /// Высота окна
- ///
- private int? _pictureHeight;
- ///
- /// Левая координата прорисовки автомобиля
- ///
- private int? _startPosX;
- ///
- /// Верхняя кооридната прорисовки автомобиля
- ///
- private int? _startPosY;
- ///
- /// Ширина прорисовки автомобиля
- ///
- private readonly int _drawningAccordionBusWidth = 180;
- ///
- /// Высота прорисовки автомобиля
- ///
- private readonly int _drawningAccordionBusHeight = 40;
- ///
- /// Инициализация свойств
- ///
- /// Скорость
- /// Вес
- /// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия стёкол
- /// Признак наличия дверей
- /// Признак наличия дисков
- /// /// Признак наличия гармошки
- public void Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool bodyGlass, bool door, bool disk, bool garmoshka)
- {
- EntityAccordionBus = new EntityAccordionBus();
- EntityAccordionBus.Init(speed, weight, bodyColor, additionalColor,
- bodyGlass, door, disk, garmoshka);
- _pictureWidth = null;
- _pictureHeight = null;
- _startPosX = null;
- _startPosY = null;
- }
- ///
- /// Установка границ поля
- ///
- /// Ширина поля
- /// Высота поля
- /// true - границы заданы, false - проверка не пройдена, нельзя
- public bool SetPictureSize(int width, int height)
- {
- if (_drawningAccordionBusWidth <= width && _drawningAccordionBusHeight <= height)
- {
- _pictureWidth = width;
- _pictureHeight = height;
- if (_startPosX.HasValue && _startPosY.HasValue)
- {
- if (_startPosX + _drawningAccordionBusWidth > _pictureWidth)
- {
- _startPosX = _pictureWidth - _drawningAccordionBusWidth;
- }
-
- if (_startPosY + _drawningAccordionBusHeight > _pictureHeight)
- {
- _startPosY = _pictureHeight - _drawningAccordionBusHeight;
- }
- }
- return true;
- }
- return false;
- }
- ///
- /// Установка позиции
- ///
- /// Координата X
- /// Координата Y
- public void SetPosition(int x, int y)
- {
- if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
- {
- return;
- }
- if (x < 0) x = 0;
- else if (x + _drawningAccordionBusWidth > _pictureWidth) x = _pictureWidth.Value - _drawningAccordionBusWidth;
-
- if (y < 0) y = 0;
- else if (y + _drawningAccordionBusHeight > _pictureHeight) y = _pictureHeight.Value - _drawningAccordionBusHeight;
- _startPosX = x;
- _startPosY = y;
- }
- public bool MoveTransport(DirectionType direction)
- {
- if (EntityAccordionBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
- return false;
- switch (direction)
- {
- //влево
- case DirectionType.Left:
- if (_startPosX.Value - EntityAccordionBus.Step > 0)
- _startPosX -= (int)EntityAccordionBus.Step;
- return true;
- //вверх
- case DirectionType.Up:
- if (_startPosY.Value - EntityAccordionBus.Step > 0)
- _startPosY -= (int)EntityAccordionBus.Step;
- return true;
- // вправо
- case DirectionType.Right:
- if(_startPosX.Value + _drawningAccordionBusWidth + EntityAccordionBus.Step < _pictureWidth)
- _startPosX += (int)EntityAccordionBus.Step;
- return true;
- //вниз
- case DirectionType.Down:
- if (_startPosY.Value + _drawningAccordionBusHeight+EntityAccordionBus.Step < _pictureHeight)
- _startPosY += (int)EntityAccordionBus.Step;
- return true;
- default:
- return false;
- }
- }
- ///
- /// Прорисовка объекта
- ///
- ///
- public void DrawTransport(Graphics g)
- {
- if (EntityAccordionBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
- return;
- //кузов
- Brush br = new SolidBrush(EntityAccordionBus.BodyColor);
- g.FillRectangle(br,_startPosX.Value, _startPosY.Value, 70, 30);
- g.FillRectangle(br, _startPosX.Value+110, _startPosY.Value, 70, 30);
- if (EntityAccordionBus.bodyGarmoshka)
- {
- g.DrawRectangle(new Pen(Color.Black), _startPosX.Value + 70, _startPosY.Value, 40, 30);
- g.FillRectangle(new HatchBrush(HatchStyle.Vertical,Color.Black,EntityAccordionBus.BodyColor), _startPosX.Value+70, _startPosY.Value, 40, 30);
- }
-
- g.DrawRectangle(new Pen(Color.Black), _startPosX.Value, _startPosY.Value, 70, 30);
- g.DrawRectangle(new Pen(Color.Black), _startPosX.Value+110, _startPosY.Value, 70, 30);
-
- //колёса
- if (EntityAccordionBus.bodyDisk)
- {
- //диски
- Brush brWhite = new SolidBrush(Color.White);
- g.FillEllipse(brWhite, _startPosX.Value, _startPosY.Value + 25, 20, 15);
- g.FillEllipse(brWhite, _startPosX.Value + 50, _startPosY.Value + 25, 20, 15);
- Brush brWheel = new SolidBrush(EntityAccordionBus.AdditionalColor);
- g.FillEllipse(brWheel, _startPosX.Value, _startPosY.Value + 25, 20, 15);
- g.FillEllipse(brWheel, _startPosX.Value + 50, _startPosY.Value + 25, 20, 15);
- g.FillEllipse(brWheel, _startPosX.Value + 110, _startPosY.Value + 25, 20, 15);
- g.FillEllipse(brWheel, _startPosX.Value + 160, _startPosY.Value + 25, 20, 15);
- }
- Pen penWheel = new Pen(Color.Black);
- g.DrawEllipse(penWheel, _startPosX.Value, _startPosY.Value + 25, 20, 15);
- g.DrawEllipse(penWheel, _startPosX.Value + 50, _startPosY.Value + 25, 20, 15);
- g.DrawEllipse(penWheel, _startPosX.Value + 110, _startPosY.Value + 25, 20, 15);
- g.DrawEllipse(penWheel, _startPosX.Value + 160, _startPosY.Value + 25, 20, 15);
- //стекла
- if (EntityAccordionBus.bodyGlass)
- {
- Brush brBlue = new SolidBrush(Color.LightBlue);
- g.FillEllipse(brBlue, _startPosX.Value + 10, _startPosY.Value + 5, 10, 15);
- g.FillEllipse(brBlue, _startPosX.Value + 55, _startPosY.Value + 5, 10, 15);
- g.FillEllipse(brBlue, _startPosX.Value + 115, _startPosY.Value + 5, 10, 15);
- g.FillEllipse(brBlue, _startPosX.Value + 165, _startPosY.Value + 5, 10, 15);
- Pen penGlass = new Pen(Color.Black);
- g.DrawEllipse(penGlass, _startPosX.Value + 10, _startPosY.Value + 5, 10, 15);
- g.DrawEllipse(penGlass, _startPosX.Value + 55, _startPosY.Value + 5, 10, 15);
- g.DrawEllipse(penGlass, _startPosX.Value + 115, _startPosY.Value + 5, 10, 15);
- g.DrawEllipse(penGlass, _startPosX.Value + 165, _startPosY.Value + 5, 10, 15);
- }
- //двери
- if (EntityAccordionBus.bodyDoor)
- {
- Brush brDoor = new SolidBrush(Color.Black);
- g.FillRectangle(brDoor, _startPosX.Value + 45, _startPosY.Value + 10, 5, 20);
- g.FillRectangle(brDoor, _startPosX.Value + 25, _startPosY.Value + 10, 5, 20);
- g.FillRectangle(brDoor, _startPosX.Value + 135, _startPosY.Value + 10, 5, 20);
- g.FillRectangle(brDoor, _startPosX.Value + 155, _startPosY.Value + 10, 5, 20);
- }
- }
-}
-
diff --git a/AccordionBus/AccordionBus/DirectionType.cs b/AccordionBus/AccordionBus/Drawnings/DirectionType.cs
similarity index 85%
rename from AccordionBus/AccordionBus/DirectionType.cs
rename to AccordionBus/AccordionBus/Drawnings/DirectionType.cs
index b32af2a..7ddcd8d 100644
--- a/AccordionBus/AccordionBus/DirectionType.cs
+++ b/AccordionBus/AccordionBus/Drawnings/DirectionType.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace AccordionBus;
+namespace AccordionBus.Drawnings;
public enum DirectionType
{
diff --git a/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs
new file mode 100644
index 0000000..0e21394
--- /dev/null
+++ b/AccordionBus/AccordionBus/Drawnings/DrawningAccordionBus.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AccordionBus.Drawnings;
+using AccordionBus.Entities;
+
+namespace AccordionBus.Drawnings;
+public class DrawningAccordionBus:DrawningBus
+{
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия стёкол
+ /// Признак наличия дверей
+ /// Признак наличия дисков
+ /// /// Признак наличия гармошки
+
+ public DrawningAccordionBus(int speed, double weight, Color bodyColor, Color
+ additionalColor, bool bodyGlass, bool door, bool disk, bool garmoshka):base(180,40)
+ {
+ EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor,
+ bodyGlass, door, disk, garmoshka);
+ }
+
+ public override void DrawTransport(Graphics g)
+ {
+ if(EntityBus == null || EntityBus is not EntityAccordionBus accordionBus || !_startPosX.HasValue || !_startPosY.HasValue)
+ return;
+ base.DrawTransport(g);
+
+ if (accordionBus.BodyGarmoshka)
+ {
+ g.DrawRectangle(new Pen(Color.Black), _startPosX.Value + 70, _startPosY.Value, 40, 30);
+ g.FillRectangle(new HatchBrush(HatchStyle.Vertical, Color.Black, EntityBus.BodyColor), _startPosX.Value + 70, _startPosY.Value, 40, 30);
+ }
+
+ g.DrawRectangle(new Pen(Color.Black), _startPosX.Value, _startPosY.Value, 70, 30);
+ g.DrawRectangle(new Pen(Color.Black), _startPosX.Value + 110, _startPosY.Value, 70, 30);
+
+ //колёса
+ if (accordionBus.BodyDisk)
+ {
+ //диски
+ Brush brWhite = new SolidBrush(Color.White);
+ g.FillEllipse(brWhite, _startPosX.Value, _startPosY.Value + 25, 20, 15);
+ g.FillEllipse(brWhite, _startPosX.Value + 50, _startPosY.Value + 25, 20, 15);
+ Brush brWheel = new SolidBrush(accordionBus.AdditionalColor);
+ g.FillEllipse(brWheel, _startPosX.Value, _startPosY.Value + 25, 20, 15);
+ g.FillEllipse(brWheel, _startPosX.Value + 50, _startPosY.Value + 25, 20, 15);
+ g.FillEllipse(brWheel, _startPosX.Value + 110, _startPosY.Value + 25, 20, 15);
+ g.FillEllipse(brWheel, _startPosX.Value + 160, _startPosY.Value + 25, 20, 15);
+ }
+ Pen penWheel = new Pen(Color.Black);
+ g.DrawEllipse(penWheel, _startPosX.Value, _startPosY.Value + 25, 20, 15);
+ g.DrawEllipse(penWheel, _startPosX.Value + 50, _startPosY.Value + 25, 20, 15);
+ g.DrawEllipse(penWheel, _startPosX.Value + 110, _startPosY.Value + 25, 20, 15);
+ g.DrawEllipse(penWheel, _startPosX.Value + 160, _startPosY.Value + 25, 20, 15);
+ //стекла
+ if (accordionBus.BodyGlass)
+ {
+ Brush brBlue = new SolidBrush(Color.LightBlue);
+ g.FillEllipse(brBlue, _startPosX.Value + 10, _startPosY.Value + 5, 10, 15);
+ g.FillEllipse(brBlue, _startPosX.Value + 55, _startPosY.Value + 5, 10, 15);
+ g.FillEllipse(brBlue, _startPosX.Value + 115, _startPosY.Value + 5, 10, 15);
+ g.FillEllipse(brBlue, _startPosX.Value + 165, _startPosY.Value + 5, 10, 15);
+ Pen penGlass = new Pen(Color.Black);
+ g.DrawEllipse(penGlass, _startPosX.Value + 10, _startPosY.Value + 5, 10, 15);
+ g.DrawEllipse(penGlass, _startPosX.Value + 55, _startPosY.Value + 5, 10, 15);
+ g.DrawEllipse(penGlass, _startPosX.Value + 115, _startPosY.Value + 5, 10, 15);
+ g.DrawEllipse(penGlass, _startPosX.Value + 165, _startPosY.Value + 5, 10, 15);
+ }
+ //двери
+ if (accordionBus.BodyDoor)
+ {
+ Brush brDoor = new SolidBrush(Color.Black);
+ g.FillRectangle(brDoor, _startPosX.Value + 45, _startPosY.Value + 10, 5, 20);
+ g.FillRectangle(brDoor, _startPosX.Value + 25, _startPosY.Value + 10, 5, 20);
+ g.FillRectangle(brDoor, _startPosX.Value + 135, _startPosY.Value + 10, 5, 20);
+ g.FillRectangle(brDoor, _startPosX.Value + 155, _startPosY.Value + 10, 5, 20);
+ }
+ }
+}
+
diff --git a/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs b/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs
new file mode 100644
index 0000000..00c4421
--- /dev/null
+++ b/AccordionBus/AccordionBus/Drawnings/DrawningBus.cs
@@ -0,0 +1,174 @@
+using AccordionBus.Entities;
+using System;
+using System.Collections.Generic;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccordionBus.Drawnings;
+
+public class DrawningBus
+{
+ ///
+ /// Класс-сущность
+ ///
+ public EntityBus? EntityBus { get; protected set; }
+ ///
+ /// Ширина окна
+ ///
+ private int? _pictureWidth;
+ ///
+ /// Высота окна
+ ///
+ private int? _pictureHeight;
+ ///
+ /// Левая координата прорисовки автомобиля
+ ///
+ protected int? _startPosX;
+ ///
+ /// Верхняя кооридната прорисовки автомобиля
+ ///
+ protected int? _startPosY;
+ ///
+ /// Ширина прорисовки автомобиля
+ ///
+ private readonly int _drawningBusWidth = 180;
+ ///
+ /// Высота прорисовки автомобиля
+ ///
+ private readonly int _drawningBusHeight = 40;
+ ///
+ /// Пустой конструктор
+ ///
+ private DrawningBus()
+ {
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+ }
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ public DrawningBus(int speed, double weight, Color bodyColor):this()
+ {
+ EntityBus = new EntityBus(speed, weight, bodyColor);
+ }
+ ///
+ /// Конструктор для наследования
+ ///
+ /// ширина автобуса
+ /// высота автобуса
+ protected DrawningBus(int drawningBusWidth, int drawningBusHeight):this()
+ {
+ _drawningBusWidth = drawningBusWidth;
+ _drawningBusHeight = drawningBusHeight;
+ }
+
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя
+ public bool SetPictureSize(int width, int height)
+ {
+ if (_drawningBusWidth <= width && _drawningBusHeight <= height)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if (_startPosX.HasValue && _startPosY.HasValue)
+ {
+ if (_startPosX + _drawningBusWidth > _pictureWidth)
+ {
+ _startPosX = _pictureWidth - _drawningBusWidth;
+ }
+
+ if (_startPosY + _drawningBusHeight > _pictureHeight)
+ {
+ _startPosY = _pictureHeight - _drawningBusHeight;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return;
+ }
+ if (x < 0) x = 0;
+ else if (x + _drawningBusWidth > _pictureWidth) x = _pictureWidth.Value - _drawningBusWidth;
+
+ if (y < 0) y = 0;
+ else if (y + _drawningBusHeight > _pictureHeight) y = _pictureHeight.Value - _drawningBusHeight;
+ _startPosX = x;
+ _startPosY = y;
+ }
+ public bool MoveTransport(DirectionType direction)
+ {
+ if (EntityBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ return false;
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX.Value - EntityBus.Step > 0)
+ _startPosX -= (int)EntityBus.Step;
+ return true;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY.Value - EntityBus.Step > 0)
+ _startPosY -= (int)EntityBus.Step;
+ return true;
+ // вправо
+ case DirectionType.Right:
+ if (_startPosX.Value + _drawningBusWidth + EntityBus.Step < _pictureWidth)
+ _startPosX += (int)EntityBus.Step;
+ return true;
+ //вниз
+ case DirectionType.Down:
+ if (_startPosY.Value + _drawningBusHeight + EntityBus.Step < _pictureHeight)
+ _startPosY += (int)EntityBus.Step;
+ return true;
+ default:
+ return false;
+ }
+ }
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public virtual void DrawTransport(Graphics g)
+ {
+ if (EntityBus == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ return;
+ //кузов
+ Brush br = new SolidBrush(EntityBus.BodyColor);
+ g.FillRectangle(br, _startPosX.Value, _startPosY.Value, 70, 30);
+ g.FillRectangle(br, _startPosX.Value + 110, _startPosY.Value, 70, 30);
+
+ g.FillRectangle(br, _startPosX.Value +70, _startPosY.Value, 40, 30);
+
+ g.DrawRectangle(new Pen(Color.Black), _startPosX.Value, _startPosY.Value, 70, 30);
+ g.DrawRectangle(new Pen(Color.Black), _startPosX.Value + 110, _startPosY.Value, 70, 30);
+
+ Pen penWheel = new Pen(Color.Black);
+ g.DrawEllipse(penWheel, _startPosX.Value, _startPosY.Value + 25, 20, 15);
+ g.DrawEllipse(penWheel, _startPosX.Value + 50, _startPosY.Value + 25, 20, 15);
+ g.DrawEllipse(penWheel, _startPosX.Value + 110, _startPosY.Value + 25, 20, 15);
+ g.DrawEllipse(penWheel, _startPosX.Value + 160, _startPosY.Value + 25, 20, 15);
+
+ }
+}
diff --git a/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs
new file mode 100644
index 0000000..a9412b8
--- /dev/null
+++ b/AccordionBus/AccordionBus/Entities/EntityAccordionBus.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccordionBus.Entities;
+public class EntityAccordionBus: EntityBus
+{
+ ///
+ /// Дополнительный цвет (для опциональных элементов)
+ ///
+ public Color AdditionalColor { get; private set; }
+ ///
+ /// Признак (опция) наличия стёкол
+ ///
+ public bool BodyGlass { get; private set; }
+ ///
+ /// Признак (опция) дверей
+ ///
+ public bool BodyDoor { get; private set; }
+ ///
+ /// Признак (опция) наличия дисков
+ ///
+ public bool BodyDisk { get; private set; }
+ ///
+ /// признак наличия гармошки
+ ///
+ public bool BodyGarmoshka { get; private set; }
+
+ ///
+ /// Инициализация полей объекта-класса автобуса с гармошкой
+ ///
+ /// Дополнительный цвет
+ /// наличие стекла
+ /// наличие дверей
+ /// наличие дисков
+ /// наличие гармошки
+
+ public EntityAccordionBus(int speed, double weigth, Color bodyColor, Color additionalColor, bool glass, bool door, bool disk, bool garmoshka) : base (speed,weigth,bodyColor)
+ {
+ AdditionalColor = additionalColor;
+ BodyGlass = glass;
+ BodyDoor = door;
+ BodyDisk = disk;
+ BodyGarmoshka = garmoshka;
+ }
+}
diff --git a/AccordionBus/AccordionBus/Entities/EntityBus.cs b/AccordionBus/AccordionBus/Entities/EntityBus.cs
new file mode 100644
index 0000000..8687085
--- /dev/null
+++ b/AccordionBus/AccordionBus/Entities/EntityBus.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AccordionBus.Entities;
+
+
+///
+/// Класс-сущность автобус
+///
+
+public class EntityBus
+{
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+ ///
+ /// Вес
+ ///
+ public double Weight { get; private set; }
+ ///
+ /// Основной цвет
+ ///
+ public Color BodyColor { get; private set; }
+
+ ///
+ /// Шаг перемещения автомобиля
+ ///
+ public double Step => Speed * 100 / Weight;
+ ///
+ /// Конструктор сущности
+ ///
+ /// Скорость
+ /// Вес автомобиля
+ /// Основной цвет
+ public EntityBus(int speed, double weight, Color bodyColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ }
+}
\ No newline at end of file
diff --git a/AccordionBus/AccordionBus/EntityAccordionBus.cs b/AccordionBus/AccordionBus/EntityAccordionBus.cs
deleted file mode 100644
index a0f8815..0000000
--- a/AccordionBus/AccordionBus/EntityAccordionBus.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace AccordionBus;
-public class EntityAccordionBus
-{
- ///
- /// Скорость
- ///
- public int Speed { get; private set; }
- ///
- /// Вес
- ///
- public double Weight { get; private set; }
- ///
- /// Основной цвет
- ///
- public Color BodyColor { get; private set; }
- ///
- /// Дополнительный цвет (для опциональных элементов)
- ///
- public Color AdditionalColor { get; private set; }
- ///
- /// Признак (опция) наличия стёкол
- ///
- public bool bodyGlass { get; private set; }
- ///
- /// Признак (опция) дверей
- ///
- public bool bodyDoor { get; private set; }
- ///
- /// Признак (опция) наличия дисков
- ///
- ///
- /// Признак (опция) наличия дисков
- ///
- public bool bodyDisk { get; private set; }
- public bool bodyGarmoshka { get; private set; }
-
- ///
- /// Шаг перемещения автомобиля
- ///
- public double Step => Speed * 100 / Weight;
- ///
- /// Инициализация полей объекта-класса спортивного автомобиля
- ///
- /// Скорость
- /// Вес автомобиля
- /// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия антикрыла
- /// Признак наличия гоночной полосы
- public void Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool glass, bool door, bool disk, bool garmoshka)
- {
- Speed = speed;
- Weight = weight;
- BodyColor = bodyColor;
- AdditionalColor = additionalColor;
- bodyGlass = glass;
- bodyDoor = door;
- bodyDisk = disk;
- bodyGarmoshka = garmoshka;
- }
-}
diff --git a/AccordionBus/AccordionBus/FormAccordionBus.Designer.cs b/AccordionBus/AccordionBus/FormAccordionBus.Designer.cs
index a7fdd31..b9c093e 100644
--- a/AccordionBus/AccordionBus/FormAccordionBus.Designer.cs
+++ b/AccordionBus/AccordionBus/FormAccordionBus.Designer.cs
@@ -32,6 +32,7 @@
buttonLeft = new Button();
buttonDown = new Button();
buttonRight = new Button();
+ buttonCreateBus = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxAccordionBus).BeginInit();
SuspendLayout();
//
@@ -48,11 +49,11 @@
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreate.Location = new Point(12, 415);
+ buttonCreate.Location = new Point(12, 421);
buttonCreate.Name = "buttonCreate";
- buttonCreate.Size = new Size(75, 23);
+ buttonCreate.Size = new Size(216, 23);
buttonCreate.TabIndex = 6;
- buttonCreate.Text = "Создать\r\n";
+ buttonCreate.Text = "Создать\r\n автобус с гармошкой";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreateAccordionBus_Click;
//
@@ -108,11 +109,23 @@
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
//
+ // buttonCreateBus
+ //
+ buttonCreateBus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonCreateBus.Location = new Point(234, 421);
+ buttonCreateBus.Name = "buttonCreateBus";
+ buttonCreateBus.Size = new Size(216, 23);
+ buttonCreateBus.TabIndex = 11;
+ buttonCreateBus.Text = "Создать\r\n автобус без гармошки";
+ buttonCreateBus.UseVisualStyleBackColor = true;
+ buttonCreateBus.Click += buttonCreateBus_Click;
+ //
// FormAccordionBus
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
+ Controls.Add(buttonCreateBus);
Controls.Add(buttonRight);
Controls.Add(buttonDown);
Controls.Add(buttonLeft);
@@ -132,5 +145,6 @@
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
+ private Button buttonCreateBus;
}
}
\ No newline at end of file
diff --git a/AccordionBus/AccordionBus/FormAccordionBus.cs b/AccordionBus/AccordionBus/FormAccordionBus.cs
index b0ba2c4..f6571fa 100644
--- a/AccordionBus/AccordionBus/FormAccordionBus.cs
+++ b/AccordionBus/AccordionBus/FormAccordionBus.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using AccordionBus.Drawnings;
namespace AccordionBus;
public partial class FormAccordionBus : Form
@@ -14,7 +15,7 @@ public partial class FormAccordionBus : Form
///
/// Поле-объект для прорисовки объекта
///
- private DrawningAccordionBus? _drawningAccordionBus;
+ private DrawningBus? _drawningBus;
///
/// Конструктор формы
///
@@ -27,39 +28,62 @@ public partial class FormAccordionBus : Form
///
private void Draw()
{
- if (_drawningAccordionBus == null)
+ if (_drawningBus == null)
{
return;
}
Bitmap bmp = new(pictureBoxAccordionBus.Width,
pictureBoxAccordionBus.Height);
Graphics gr = Graphics.FromImage(bmp);
- _drawningAccordionBus.DrawTransport(gr);
+ _drawningBus.DrawTransport(gr);
pictureBoxAccordionBus.Image = bmp;
}
+
+ ///
+ ///Создание объекта класса-перемещения
+ ///
+ /// Тип создаваемого объётека
+
+ private void CreateObject(string type)
+ {
+ Random rnd = new Random();
+ switch (type)
+ {
+ case nameof(DrawningBus):
+ _drawningBus = new DrawningBus(rnd.Next(100, 300), rnd.Next(1000, 3000),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ break;
+ case nameof(DrawningAccordionBus):
+ _drawningBus = new DrawningAccordionBus(rnd.Next(650, 700), rnd.Next(15760,16130),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),rnd.Next(0, 256)),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),rnd.Next(0, 256)),
+ Convert.ToBoolean(rnd.Next(0, 2)),
+ Convert.ToBoolean(rnd.Next(0, 2)),
+ Convert.ToBoolean(rnd.Next(0, 2)),
+ Convert.ToBoolean(rnd.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+ _drawningBus.SetPictureSize(pictureBoxAccordionBus.Width,pictureBoxAccordionBus.Height);
+ _drawningBus.SetPosition(rnd.Next(10,100), rnd.Next(10,100));
+ Draw();
+ }
+
///
- /// Обработка нажатия кнопки "Создать"
+ /// Обработка нажатия кнопки "Создать автобус с гармошкой"
///
///
///
- private void ButtonCreateAccordionBus_Click(object sender, EventArgs e)
- {
- Random random = new();
- _drawningAccordionBus = new DrawningAccordionBus();
- _drawningAccordionBus.Init(random.Next(650, 700), random.Next(15760,
- 16130),
- 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)));
- _drawningAccordionBus.SetPictureSize(pictureBoxAccordionBus.Width,
- pictureBoxAccordionBus.Height);
- _drawningAccordionBus.SetPosition(random.Next(10, 100), random.Next(10,
- 100));
- Draw();
- }
+ private void ButtonCreateAccordionBus_Click(object sender, EventArgs e) =>CreateObject(nameof(DrawningAccordionBus));
+
+ ///
+ /// Обработка нажатия кнопки "Создать автобус"
+ ///
+ ///
+ ///
+ public void buttonCreateBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus));
+
///
/// Перемещение объекта по форме (нажатие кнопок навигации)
///
@@ -67,7 +91,7 @@ public partial class FormAccordionBus : Form
///
private void ButtonMove_Click(object sender, EventArgs e)
{
- if (_drawningAccordionBus == null)
+ if (_drawningBus == null)
{
return;
}
@@ -77,19 +101,19 @@ public partial class FormAccordionBus : Form
{
case "buttonUp":
result =
- _drawningAccordionBus.MoveTransport(DirectionType.Up);
+ _drawningBus.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
result =
- _drawningAccordionBus.MoveTransport(DirectionType.Down);
+ _drawningBus.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
result =
- _drawningAccordionBus.MoveTransport(DirectionType.Left);
+ _drawningBus.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
result =
- _drawningAccordionBus.MoveTransport(DirectionType.Right);
+ _drawningBus.MoveTransport(DirectionType.Right);
break;
}
if (result)
diff --git a/AccordionBus/AccordionBus/FormAccordionBus.resx b/AccordionBus/AccordionBus/FormAccordionBus.resx
index b311afd..4a47b09 100644
--- a/AccordionBus/AccordionBus/FormAccordionBus.resx
+++ b/AccordionBus/AccordionBus/FormAccordionBus.resx
@@ -121,7 +121,7 @@
iVBORw0KGgoAAAANSUhEUgAAA5gAAAOYBAMAAABC5kGOAAAABGdBTUEAALGPC/xhBQAAABJQTFRF5ubm
- AQEB////AAAAl5eXUFBQNT5ZuQAAAAlwSFlzAAAOvQAADr0BR/uQrQAAGoFJREFUeNrt3V168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