Лабораторная работа №2
This commit is contained in:
parent
bf2857c8ca
commit
1f2abb6c1f
8
ProjectDumpTruck/DirectionType.cs
Normal file
8
ProjectDumpTruck/DirectionType.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
public Class1()
|
||||
{
|
||||
}
|
||||
}
|
8
ProjectDumpTruck/DrawningDumpTrack.cs
Normal file
8
ProjectDumpTruck/DrawningDumpTrack.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
public Class1()
|
||||
{
|
||||
}
|
||||
}
|
8
ProjectDumpTruck/DrawningTrack.cs
Normal file
8
ProjectDumpTruck/DrawningTrack.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
public Class1()
|
||||
{
|
||||
}
|
||||
}
|
8
ProjectDumpTruck/EntityDampTrack.cs
Normal file
8
ProjectDumpTruck/EntityDampTrack.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
public Class1()
|
||||
{
|
||||
}
|
||||
}
|
8
ProjectDumpTruck/EntityTrack.cs
Normal file
8
ProjectDumpTruck/EntityTrack.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
public Class1()
|
||||
{
|
||||
}
|
||||
}
|
35
ProjectDumpTruck/ProjectDumpTruck/Drawnings/DirectionType.cs
Normal file
35
ProjectDumpTruck/ProjectDumpTruck/Drawnings/DirectionType.cs
Normal file
@ -0,0 +1,35 @@
|
||||
namespace ProjectDumpTrack.Drawnings;
|
||||
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Неизвестное направление
|
||||
/// </summary>
|
||||
Unknow = -1,
|
||||
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
|
||||
|
||||
}
|
||||
|
106
ProjectDumpTruck/ProjectDumpTruck/Drawnings/DrawningDumpTrack.cs
Normal file
106
ProjectDumpTruck/ProjectDumpTruck/Drawnings/DrawningDumpTrack.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using ProjectDumpTrack.Entities;
|
||||
|
||||
namespace ProjectDumpTrack.Drawnings;
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningDumpTrack : DrawningTrack
|
||||
{
|
||||
////2 задание
|
||||
//public override bool MoveTransport(DirectionType direction)
|
||||
//{
|
||||
// if (EntityTrack == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// switch (direction)
|
||||
// {
|
||||
// //влево
|
||||
// case DirectionType.Left:
|
||||
// if (_startPosX.Value - EntityTrack.Step > 0)
|
||||
// {
|
||||
// _startPosX -= (int)EntityTrack.Step;
|
||||
// }
|
||||
// return true;
|
||||
|
||||
// //вверх
|
||||
// case DirectionType.Up:
|
||||
// if (_startPosY.Value - EntityTrack.Step > 0)
|
||||
// {
|
||||
// _startPosY -= (int)EntityTrack.Step;
|
||||
// }
|
||||
// return true;
|
||||
|
||||
// //вправо
|
||||
// case DirectionType.Right:
|
||||
// if (_startPosX.Value + EntityTrack.Step + _drawningTrackWidth < _pictureWidth)
|
||||
// {
|
||||
// _startPosX += (int)EntityTrack.Step;
|
||||
// }
|
||||
// return true;
|
||||
|
||||
// //вниз
|
||||
// case DirectionType.Down:
|
||||
// if (_startPosY.Value + EntityTrack.Step + _drawningTrackHeight < _pictureHeight)
|
||||
// {
|
||||
// _startPosY += (int)EntityTrack.Step;
|
||||
// }
|
||||
// return true;
|
||||
// default:
|
||||
// return false;
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="bodywork">Признак наличия кузова</param>
|
||||
/// <param name="awning">Признак наличия тента</param>
|
||||
|
||||
|
||||
public DrawningDumpTrack(int speed, double weight, Color bodyColor, Color additionalColor, bool bodywork, bool awning) : base(130, 100)
|
||||
{
|
||||
EntityTrack = new EntityDumpTrack(speed, weight, bodyColor, additionalColor, bodywork, awning);
|
||||
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityTrack == null || EntityTrack is not EntityDumpTrack dumpTrack || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(dumpTrack.AdditionalColor);
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
//Отрисовка кузова
|
||||
if (dumpTrack.Bodywork)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 90, 35);
|
||||
}
|
||||
|
||||
//Отрисовка тента
|
||||
if (dumpTrack.Bodywork & dumpTrack.Awning)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 95, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 95, 3);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value, 3, 40);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 70, _startPosY.Value, 3, 40);
|
||||
}
|
||||
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
246
ProjectDumpTruck/ProjectDumpTruck/Drawnings/DrawningTrack.cs
Normal file
246
ProjectDumpTruck/ProjectDumpTruck/Drawnings/DrawningTrack.cs
Normal file
@ -0,0 +1,246 @@
|
||||
|
||||
using ProjectDumpTrack.Entities;
|
||||
|
||||
namespace ProjectDumpTrack.Drawnings;
|
||||
public class DrawningTrack
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityTrack? EntityTrack { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int? _pictureWidth;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int? _pictureHeight;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки самосвала
|
||||
/// </summary>
|
||||
protected int? _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Верхняя координата прорисовки самосвала
|
||||
/// </summary>
|
||||
protected int? _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина прорисовки самосвала
|
||||
/// </summary>
|
||||
private readonly int _drawningTrackWidth = 130;
|
||||
|
||||
/// <summary>
|
||||
/// Высота прорисовки самосвала
|
||||
/// </summary>
|
||||
private readonly int _drawningTrackHeight = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Координата X объекта
|
||||
/// </summary>
|
||||
public int? GetPosX => _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Координата Y объекта
|
||||
/// </summary>
|
||||
public int? GetPosY => _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина объекта
|
||||
/// </summary>
|
||||
public int GetWidth => _drawningTrackWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Высота объекта
|
||||
/// </summary>
|
||||
public int GetHeight => _drawningTrackHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Пустой конструктор
|
||||
/// </summary>
|
||||
private DrawningTrack()
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
|
||||
|
||||
public DrawningTrack(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityTrack = new EntityTrack(speed, weight, bodyColor);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор для наследников
|
||||
/// </summary>
|
||||
/// <param name="drawningTrackWidth">Ширина прорисовки автомобиля</param>
|
||||
/// <param name="drawningTrackHeight">Высота прорисовки автомобиля</param>
|
||||
|
||||
|
||||
|
||||
protected DrawningTrack(int drawningTrackWidth, int drawningTrackHeight) : this()
|
||||
{
|
||||
_drawningTrackWidth = drawningTrackWidth;
|
||||
_drawningTrackHeight = drawningTrackHeight;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
/// <param name="width">Ширина поля</param>
|
||||
/// <param name="height">Высота поля</param>
|
||||
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
||||
public bool SetPictureSize(int width, int height)
|
||||
{
|
||||
// TODO проверка, что объект "влезает" в размеры поля
|
||||
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
|
||||
if (_drawningTrackWidth > width || _drawningTrackHeight > height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
||||
// то надо изменить координаты, чтобы он оставался в этих границах
|
||||
if (x + _drawningTrackWidth > _pictureWidth)
|
||||
{
|
||||
x -= _drawningTrackWidth;
|
||||
}
|
||||
if (y + _drawningTrackHeight > _pictureHeight)
|
||||
{
|
||||
y -= _drawningTrackHeight;
|
||||
}
|
||||
if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
if (y < 0)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns>true - перемещение выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityTrack == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityTrack.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityTrack.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityTrack.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityTrack.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
//вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + EntityTrack.Step + _drawningTrackWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityTrack.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + EntityTrack.Step + _drawningTrackHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityTrack.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityTrack == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
|
||||
//Отрисовка основы (кабины водителя и днища)
|
||||
Brush body = new SolidBrush(EntityTrack.BodyColor);
|
||||
g.FillRectangle(body, _startPosX.Value + 100, _startPosY.Value, 30, 35);
|
||||
g.FillRectangle(body, _startPosX.Value, _startPosY.Value + 40, 130, 20);
|
||||
|
||||
//Отрисовка колёс
|
||||
Brush wheels = new SolidBrush(Color.Gray);
|
||||
g.FillEllipse(wheels, _startPosX.Value, _startPosY.Value + 60, 30, 30);
|
||||
g.FillEllipse(wheels, _startPosX.Value + 30, _startPosY.Value + 60, 30, 30);
|
||||
g.FillEllipse(wheels, _startPosX.Value + 100, _startPosY.Value + 60, 30, 30);
|
||||
|
||||
//Отрисовка границ
|
||||
Brush border = new SolidBrush(Color.Black);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value, 30, 35);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 40, 130, 20);
|
||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 60, 30, 30);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 60, 30, 30);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 60, 30, 30);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
namespace ProjectDumpTrack.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность "Самосвал"
|
||||
/// </summary>
|
||||
public class EntityDumpTrack : EntityTrack
|
||||
{
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия кузова
|
||||
/// </summary>
|
||||
public bool Bodywork { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия тента
|
||||
/// </summary>
|
||||
public bool Awning { get; private set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса самосвала
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="bodywork">Признак наличия кузова</param>
|
||||
/// <param name="awning">Признак наличия тента</param>
|
||||
|
||||
public EntityDumpTrack(int speed, double weight, Color bodyColor, Color additionalColor, bool bodywork, bool awning) : base(5, 45, Color.Black)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
Bodywork = bodywork;
|
||||
Awning = awning;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
45
ProjectDumpTruck/ProjectDumpTruck/Entities/EntityTrack.cs
Normal file
45
ProjectDumpTruck/ProjectDumpTruck/Entities/EntityTrack.cs
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
namespace ProjectDumpTrack.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность "Грузовик"
|
||||
/// </summary>
|
||||
public class EntityTrack
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения самосвала
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор сущности
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
|
||||
|
||||
public EntityTrack(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,9 @@
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonCreateTrack = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStrategyStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxDumpTrack).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -51,9 +54,9 @@
|
||||
buttonCreateDumpTrack.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateDumpTrack.Location = new Point(12, 409);
|
||||
buttonCreateDumpTrack.Name = "buttonCreateDumpTrack";
|
||||
buttonCreateDumpTrack.Size = new Size(94, 29);
|
||||
buttonCreateDumpTrack.Size = new Size(210, 29);
|
||||
buttonCreateDumpTrack.TabIndex = 1;
|
||||
buttonCreateDumpTrack.Text = "Создать";
|
||||
buttonCreateDumpTrack.Text = "Создать грузовик с кузовом";
|
||||
buttonCreateDumpTrack.UseVisualStyleBackColor = true;
|
||||
buttonCreateDumpTrack.Click += buttonCreateDumpTrack_Click;
|
||||
//
|
||||
@ -105,11 +108,45 @@
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonCreateTrack
|
||||
//
|
||||
buttonCreateTrack.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateTrack.Location = new Point(238, 409);
|
||||
buttonCreateTrack.Name = "buttonCreateTrack";
|
||||
buttonCreateTrack.Size = new Size(210, 29);
|
||||
buttonCreateTrack.TabIndex = 6;
|
||||
buttonCreateTrack.Text = "Создать грузовик";
|
||||
buttonCreateTrack.UseVisualStyleBackColor = true;
|
||||
buttonCreateTrack.Click += buttonCreateTrack_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
|
||||
comboBoxStrategy.Location = new Point(670, 12);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(112, 23);
|
||||
comboBoxStrategy.TabIndex = 7;
|
||||
//
|
||||
// buttonStrategyStep
|
||||
//
|
||||
buttonStrategyStep.Location = new Point(721, 41);
|
||||
buttonStrategyStep.Name = "buttonStrategyStep";
|
||||
buttonStrategyStep.Size = new Size(61, 22);
|
||||
buttonStrategyStep.TabIndex = 8;
|
||||
buttonStrategyStep.Text = "Шаг";
|
||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
||||
buttonStrategyStep.Click += ButtonStrategyStep_Click;
|
||||
//
|
||||
// FormTransport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonStrategyStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreateTrack);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
@ -130,5 +167,8 @@
|
||||
internal Button buttonRight;
|
||||
internal Button buttonUp;
|
||||
internal Button buttonDown;
|
||||
private Button buttonCreateTrack;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStrategyStep;
|
||||
}
|
||||
}
|
@ -1,4 +1,8 @@
|
||||
/// <summary>
|
||||
|
||||
using ProjectDumpTrack.Drawnings;
|
||||
using ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Форма работы с объектом "Самосвал"
|
||||
/// </summary>
|
||||
namespace ProjectDumpTruck
|
||||
@ -8,14 +12,19 @@ namespace ProjectDumpTruck
|
||||
/// <summary>
|
||||
/// Поле-объект для прорисовки объекта
|
||||
/// </summary>
|
||||
private DrawningDumpTrack? _drawningDumpTrack;
|
||||
private DrawningTrack? _drawningTrack;
|
||||
|
||||
/// <summary>
|
||||
/// Стратегия перемещения
|
||||
/// </summary>
|
||||
private AbstractStrategy? _strategy;
|
||||
/// <summary>
|
||||
/// Конструктор формы
|
||||
/// </summary>
|
||||
public FormTransport()
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategy = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -23,38 +32,65 @@ namespace ProjectDumpTruck
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningDumpTrack == null)
|
||||
if (_drawningTrack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap bmp = new(pictureBoxDumpTrack.Width, pictureBoxDumpTrack.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningDumpTrack.DrawTransport(gr);
|
||||
_drawningTrack.DrawTransport(gr);
|
||||
pictureBoxDumpTrack.Image = bmp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать"
|
||||
/// Создание объекта класса-перемещения
|
||||
/// </summary>
|
||||
/// <param name="type">Тип создаваемого объекта</param>
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
Random random = new();
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningTrack):
|
||||
_drawningTrack = new DrawningTrack(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||
break;
|
||||
case nameof(DrawningDumpTrack):
|
||||
_drawningTrack = new DrawningDumpTrack(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)),
|
||||
Convert.ToBoolean(random.Next(1, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
_drawningTrack.SetPictureSize(pictureBoxDumpTrack.Width, pictureBoxDumpTrack.Height);
|
||||
_drawningTrack.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
_strategy = null;
|
||||
comboBoxStrategy.Enabled = true;
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать грузовик с кузовом"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreateDumpTrack_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningDumpTrack = new DrawningDumpTrack();
|
||||
_drawningDumpTrack.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)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
|
||||
_drawningDumpTrack.SetPictureSize(pictureBoxDumpTrack.Width, pictureBoxDumpTrack.Height);
|
||||
_drawningDumpTrack.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
private void buttonCreateDumpTrack_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningDumpTrack));
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать грузовик"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreateTrack_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrack));
|
||||
|
||||
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||
/// </summary>
|
||||
@ -62,7 +98,7 @@ namespace ProjectDumpTruck
|
||||
/// <param name="e"></param>
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningDumpTrack == null)
|
||||
if (_drawningTrack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -72,16 +108,16 @@ namespace ProjectDumpTruck
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawningDumpTrack.MoveTransport(DirectionType.Up);
|
||||
result = _drawningTrack.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawningDumpTrack.MoveTransport(DirectionType.Down);
|
||||
result = _drawningTrack.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawningDumpTrack.MoveTransport(DirectionType.Left);
|
||||
result = _drawningTrack.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _drawningDumpTrack.MoveTransport(DirectionType.Right);
|
||||
result = _drawningTrack.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
@ -89,5 +125,48 @@ namespace ProjectDumpTruck
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonStrategyStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningTrack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_strategy.SetData(new MoveableTrack(_drawningTrack), pictureBoxDumpTrack.Width, pictureBoxDumpTrack.Height);
|
||||
}
|
||||
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
comboBoxStrategy.Enabled = false;
|
||||
_strategy.MakeStep();
|
||||
Draw();
|
||||
|
||||
if (_strategy.GetStatus() == StrategyStatus.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
|
||||
namespace ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-стратегия перемещения объекта
|
||||
/// </summary>
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
////Абстрактный метод 3 задание
|
||||
//public abstract void MyAbstractMethod();
|
||||
|
||||
/// <summary>
|
||||
/// Перемещаемый объект
|
||||
/// </summary>
|
||||
private IMoveableObject? _moveableObject;
|
||||
|
||||
/// <summary>
|
||||
/// Статус перемещения
|
||||
/// </summary>
|
||||
private StrategyStatus _state = StrategyStatus.NotInit;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина поля
|
||||
/// </summary>
|
||||
protected int FieldWidth { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Высота поля
|
||||
/// </summary>
|
||||
protected int FieldHeight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Статус перемещения
|
||||
/// </summary>
|
||||
public StrategyStatus GetStatus() { return _state; }
|
||||
|
||||
/// <summary>
|
||||
/// Установка данных
|
||||
/// </summary>
|
||||
/// <param name="moveableObject">Перемещаемый объект</param>
|
||||
/// <param name="width">Ширина поля</param>
|
||||
/// <param name="height">Высота поля</param>
|
||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
||||
{
|
||||
if (moveableObject == null)
|
||||
{
|
||||
_state = StrategyStatus.NotInit;
|
||||
return;
|
||||
}
|
||||
|
||||
_state = StrategyStatus.InProgress;
|
||||
_moveableObject = moveableObject;
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != StrategyStatus.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsTargetDestinaion())
|
||||
{
|
||||
_state = StrategyStatus.Finish;
|
||||
return;
|
||||
}
|
||||
|
||||
MoveToTarget();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение влево
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveLeft() => MoveTo(MovementDirection.Left);
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение вправо
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveRight() => MoveTo(MovementDirection.Right);
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение вверх
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveUp() => MoveTo(MovementDirection.Up);
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение вниз
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveDown() => MoveTo(MovementDirection.Down);
|
||||
|
||||
/// <summary>
|
||||
/// Параметры объекта
|
||||
/// </summary>
|
||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
||||
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != StrategyStatus.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение к цели
|
||||
/// </summary>
|
||||
protected abstract void MoveToTarget();
|
||||
|
||||
/// <summary>
|
||||
/// Достигнута ли цель
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected abstract bool IsTargetDestinaion();
|
||||
|
||||
/// <summary>
|
||||
/// Попытка перемещения в требуемом направлении
|
||||
/// </summary>
|
||||
/// <param name="movementDirection">Направление</param>
|
||||
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
|
||||
private bool MoveTo(MovementDirection movementDirection)
|
||||
{
|
||||
if (_state != StrategyStatus.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _moveableObject?.TryMoveObject(movementDirection) ?? false;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
|
||||
namespace ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Интерфейс для работы с перемещаемым объектом
|
||||
/// </summary>
|
||||
public interface IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение координаты объекта
|
||||
/// </summary>
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
int GetStep { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Попытка переместить объект в указанном направлении
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns>true - объект перемещен, false - перемещение невозможно</returns>
|
||||
bool TryMoveObject(MovementDirection direction);
|
||||
|
||||
////Интерфейс - задание 1
|
||||
//void MyMethod();
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
|
||||
namespace ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
public class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
////Абстрактный метод 3 задание
|
||||
//public override void MyAbstractMethod()
|
||||
//{
|
||||
// Console.WriteLine("Implementation of abstract method in derived class");
|
||||
//}
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return objParams.RightBorder <= FieldWidth && objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder <= FieldHeight && objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int diffX = objParams.RightBorder - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
|
||||
int diffY = objParams.DownBorder - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
|
||||
namespace ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Стратегия перемещения объекта в центр экрана
|
||||
/// </summary>
|
||||
public class MoveToCenter : AbstractStrategy
|
||||
{
|
||||
////Абстрактный метод 3 задание
|
||||
//public override void MyAbstractMethod()
|
||||
//{
|
||||
// Console.WriteLine("Implementation of abstract method in derived class");
|
||||
//}
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
|
||||
int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
|
||||
using ProjectDumpTrack.Drawnings;
|
||||
|
||||
namespace ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-реализация IMoveableObject с использованием DrawningTrack
|
||||
/// </summary>
|
||||
public class MoveableTrack : IMoveableObject
|
||||
{
|
||||
////Интерфейс-задание 1
|
||||
//public void MyMethod()
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Поле-объект класса DrawningCar или его наследника
|
||||
/// </summary>
|
||||
private readonly DrawningTrack? _track = null;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="car">Объект класса DrawningCar</param>
|
||||
public MoveableTrack(DrawningTrack track)
|
||||
{
|
||||
_track = track;
|
||||
}
|
||||
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_track == null || _track.EntityTrack == null || !_track.GetPosX.HasValue || !_track.GetPosY.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_track.GetPosX.Value, _track.GetPosY.Value, _track.GetWidth, _track.GetHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetStep => (int)(_track?.EntityTrack?.Step ?? 0);
|
||||
|
||||
public bool TryMoveObject(MovementDirection direction)
|
||||
{
|
||||
if (_track == null || _track.EntityTrack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _track.MoveTransport(GetDirectionType(direction));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конвертация из MovementDirection в DirectionType
|
||||
/// </summary>
|
||||
/// <param name="direction">MovementDirection</param>
|
||||
/// <returns>DirectionType</returns>
|
||||
private static DirectionType GetDirectionType(MovementDirection direction)
|
||||
{
|
||||
return direction switch
|
||||
{
|
||||
MovementDirection.Left => DirectionType.Left,
|
||||
MovementDirection.Right => DirectionType.Right,
|
||||
MovementDirection.Up => DirectionType.Up,
|
||||
MovementDirection.Down => DirectionType.Down,
|
||||
_ => DirectionType.Unknow,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
|
||||
namespace ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
public enum MovementDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
|
||||
namespace ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Параметры-координаты объекта
|
||||
/// </summary>
|
||||
public class ObjectParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// Координата X
|
||||
/// </summary>
|
||||
private readonly int _x;
|
||||
|
||||
/// <summary>
|
||||
/// Координата Y
|
||||
/// </summary>
|
||||
private readonly int _y;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина объекта
|
||||
/// </summary>
|
||||
private readonly int _width;
|
||||
|
||||
/// <summary>
|
||||
/// Высота объекта
|
||||
/// </summary>
|
||||
private readonly int _height;
|
||||
|
||||
/// <summary>
|
||||
/// Левая граница
|
||||
/// </summary>
|
||||
public int LeftBorder => _x;
|
||||
|
||||
/// <summary>
|
||||
/// Верхняя граница
|
||||
/// </summary>
|
||||
public int TopBorder => _y;
|
||||
|
||||
/// <summary>
|
||||
/// Правая граница
|
||||
/// </summary>
|
||||
public int RightBorder => _x + _width;
|
||||
|
||||
/// <summary>
|
||||
/// Нижняя граница
|
||||
/// </summary>
|
||||
public int DownBorder => _y + _height;
|
||||
|
||||
/// <summary>
|
||||
/// Середина объекта
|
||||
/// </summary>
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Середина объекта
|
||||
/// </summary>
|
||||
public int ObjectMiddleVertical => _y + _height / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина объекта</param>
|
||||
/// <param name="height">Высота объекта</param>
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
|
||||
namespace ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Статус выполнения операции перемещения
|
||||
/// </summary>
|
||||
public enum StrategyStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Все готово к началу
|
||||
/// </summary>
|
||||
NotInit,
|
||||
|
||||
/// <summary>
|
||||
/// Выполняется
|
||||
/// </summary>
|
||||
InProgress,
|
||||
|
||||
/// <summary>
|
||||
/// Завершено
|
||||
/// </summary>
|
||||
Finish
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
using ProjectDumpTruck.MovementStrategy;
|
||||
|
||||
namespace ProjectDumpTruck
|
||||
{
|
||||
internal static class Program
|
||||
@ -12,7 +14,15 @@ namespace ProjectDumpTruck
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormTransport());
|
||||
|
||||
|
||||
|
||||
////Àáñòðàêòíûé ìåòîä 3 çàäàíèå
|
||||
//AbstractStrategy myObject1 = new MoveToBorder();
|
||||
//myObject1.MyAbstractMethod();
|
||||
|
||||
//AbstractStrategy myObject2 = new MoveToCenter();
|
||||
//myObject2.MyAbstractMethod();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user