Добавление родителей и ввод конструкторов.
This commit is contained in:
parent
18c757b9ec
commit
3562fd7940
@ -1,32 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LabOOP_1
|
|
||||||
{
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down = 2,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left = 3,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right = 4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
31
LabOOP_1/LabOOP_1/Drawnings/DirectionType.cs
Normal file
31
LabOOP_1/LabOOP_1/Drawnings/DirectionType.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Project_Catamaran.Drawnings;
|
||||||
|
|
||||||
|
public enum DirectionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Вверх
|
||||||
|
/// </summary>
|
||||||
|
Up = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Вниз
|
||||||
|
/// </summary>
|
||||||
|
Down = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Влево
|
||||||
|
/// </summary>
|
||||||
|
Left = 3,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Вправо
|
||||||
|
/// </summary>
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
|
81
LabOOP_1/LabOOP_1/Drawnings/DrawningCatamaran.cs
Normal file
81
LabOOP_1/LabOOP_1/Drawnings/DrawningCatamaran.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
using Project_Catamaran.Entities;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Xml.Resolvers;
|
||||||
|
|
||||||
|
namespace Project_Catamaran.Drawnings;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||||
|
/// </summary>
|
||||||
|
public class DrawningCatamaran : DrawningSimpleCatamaran
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес катамарана</param>
|
||||||
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="deck">Признак наличия палубы</param>
|
||||||
|
/// <param name="sail">Признак наличия мачты</param>
|
||||||
|
/// <param name="floats">Признак наличия поплавков</param>
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail, bool deck) : base(100, 90, bodyColor)
|
||||||
|
{
|
||||||
|
EntitySimpleCatamaran = new EntityCatamaran(speed, weight, bodyColor, additionalColor, floats, sail, deck);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public override void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntitySimpleCatamaran == null || EntitySimpleCatamaran is not EntityCatamaran catamaran || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
pen.Width = 2;
|
||||||
|
Brush additionalBrush = new SolidBrush(catamaran.AdditionalColor);
|
||||||
|
|
||||||
|
// палуба
|
||||||
|
if (catamaran.Deck)
|
||||||
|
{
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX.Value + 15, _startPosY.Value + 40, 60, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (catamaran.Sail)
|
||||||
|
{
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 40, _startPosY.Value + 50, _startPosX.Value + 75, _startPosY.Value + 30);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 75, _startPosY.Value + 30, _startPosX.Value + 110, _startPosY.Value + 35);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 110, _startPosY.Value + 35, _startPosX.Value + 50, _startPosY.Value + 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
_startPosX += 10;
|
||||||
|
_startPosY += 10;
|
||||||
|
|
||||||
|
base.DrawTransport(g);
|
||||||
|
|
||||||
|
_startPosX -= 10;
|
||||||
|
_startPosY -= 10;
|
||||||
|
|
||||||
|
if (catamaran.Floats)
|
||||||
|
{
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 60, _startPosX.Value + 45, _startPosY.Value + 75);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 40, _startPosX.Value + 45, _startPosY.Value + 25);
|
||||||
|
g.DrawEllipse(pen, _startPosX.Value + 0, _startPosY.Value + 75, 100, 15);
|
||||||
|
g.DrawEllipse(pen, _startPosX.Value + 0, _startPosY.Value + 10, 100, 15);
|
||||||
|
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX.Value + 0, _startPosY.Value + 75, 100, 15);
|
||||||
|
g.FillEllipse(additionalBrush, _startPosX.Value + 0, _startPosY.Value + 10, 100, 15);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,18 @@
|
|||||||
using LabOOP_1;
|
using Project_Catamaran.Entities;
|
||||||
using System.Xml.Resolvers;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ProjectCatamaran;
|
namespace Project_Catamaran.Drawnings;
|
||||||
|
|
||||||
/// <summary>
|
public class DrawningSimpleCatamaran
|
||||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
|
||||||
/// </summary>
|
|
||||||
public class DrawningCatamaran
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityCatamaran? EntityCatamaran { get; private set; }
|
public EntitySimpleCatamaran? EntitySimpleCatamaran { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
@ -26,43 +27,62 @@ public class DrawningCatamaran
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки катамарана
|
/// Левая координата прорисовки катамарана
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int? _startPosX;
|
protected int? _startPosX;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Верхняя кооридната прорисовки катамарана
|
/// Верхняя кооридната прорисовки катамарана
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int? _startPosY;
|
protected int? _startPosY;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки катамарана
|
/// Ширина прорисовки катамарана
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningCatamaranWidth = 110;
|
private readonly int _drawningCatamaranWidth = 90;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки катамарана
|
/// Высота прорисовки катамарана
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningCatamaranHeight = 90;
|
private readonly int _drawningCatamaranHeight = 60;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация свойств
|
/// Пустой конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="speed">Скорость</param>
|
///
|
||||||
/// <param name="weight">Вес</param>
|
private DrawningSimpleCatamaran()
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
|
||||||
/// <param name="sail">Признак наличия мачты</param>
|
|
||||||
/// <param name="floats">Признак наличия поплавков</param>
|
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool sail, bool floats)
|
|
||||||
{
|
{
|
||||||
EntityCatamaran = new EntityCatamaran();
|
|
||||||
EntityCatamaran.Init(speed, weight, bodyColor, additionalColor, bodyKit, sail, floats);
|
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
_startPosX = null;
|
_startPosX = null;
|
||||||
_startPosY = null;
|
_startPosY = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес</param>
|
||||||
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
|
|
||||||
|
public DrawningSimpleCatamaran(int speed, double weight, Color bodyColor) : this()
|
||||||
|
{
|
||||||
|
EntitySimpleCatamaran = new EntitySimpleCatamaran(speed, weight, bodyColor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор для наследников
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawningCatamaranWidth">Ширина прорисовки автомобиля</param>
|
||||||
|
/// <param name="drawningCatamaranHeight">Высота прорисовки автомобиля</param>
|
||||||
|
|
||||||
|
protected DrawningSimpleCatamaran(int drawningCatamaranWidth, int drawningCatamaranHeight) : this()
|
||||||
|
{
|
||||||
|
_drawningCatamaranWidth = drawningCatamaranWidth;
|
||||||
|
_drawningCatamaranHeight = drawningCatamaranHeight;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка границ поля
|
/// Установка границ поля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -136,7 +156,7 @@ public class DrawningCatamaran
|
|||||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
||||||
public bool MoveTransport(DirectionType direction)
|
public bool MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityCatamaran == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntitySimpleCatamaran == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -145,31 +165,31 @@ public class DrawningCatamaran
|
|||||||
{
|
{
|
||||||
//влево
|
//влево
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
if (_startPosX.Value - EntityCatamaran.Step > 0)
|
if (_startPosX.Value - EntitySimpleCatamaran.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= (int)EntityCatamaran.Step;
|
_startPosX -= (int)EntitySimpleCatamaran.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
//вверх
|
//вверх
|
||||||
case DirectionType.Up:
|
case DirectionType.Up:
|
||||||
if (_startPosY.Value - EntityCatamaran.Step > 0)
|
if (_startPosY.Value - EntitySimpleCatamaran.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosY -= (int)EntityCatamaran.Step;
|
_startPosY -= (int)EntitySimpleCatamaran.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
// вправо
|
// вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
if (_startPosX.Value + EntityCatamaran.Step + _drawningCatamaranWidth < _pictureWidth)
|
if (_startPosX.Value + EntitySimpleCatamaran.Step + _drawningCatamaranWidth < _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX += (int)EntityCatamaran.Step;
|
_startPosX += (int)EntitySimpleCatamaran.Step;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
//вниз
|
//вниз
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
if (_startPosY.Value + EntityCatamaran.Step + _drawningCatamaranHeight < _pictureHeight)
|
if (_startPosY.Value + EntitySimpleCatamaran.Step + _drawningCatamaranHeight < _pictureHeight)
|
||||||
{
|
{
|
||||||
_startPosY += (int)EntityCatamaran.Step;
|
_startPosY += (int)EntitySimpleCatamaran.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -181,56 +201,28 @@ public class DrawningCatamaran
|
|||||||
/// Прорисовка объекта
|
/// Прорисовка объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityCatamaran == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
pen.Width = 2;
|
pen.Width = 2;
|
||||||
Brush additionalBrush = new SolidBrush(EntityCatamaran.AdditionalColor);
|
|
||||||
|
|
||||||
// палуба
|
|
||||||
if (EntityCatamaran.Deck)
|
|
||||||
{
|
|
||||||
g.FillEllipse(additionalBrush, _startPosX.Value + 15, _startPosY.Value + 40, 60, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (EntityCatamaran.Sail)
|
|
||||||
{
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 40, _startPosY.Value + 50, _startPosX.Value + 75, _startPosY.Value + 30);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 75, _startPosY.Value + 30, _startPosX.Value + 110, _startPosY.Value + 35);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 110, _startPosY.Value + 35, _startPosX.Value + 50, _startPosY.Value + 40);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//границы судна
|
//границы судна
|
||||||
g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 60, _startPosX.Value + 80, _startPosY.Value + 60);
|
g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 50, _startPosX.Value + 70, _startPosY.Value + 50);
|
||||||
g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 60, _startPosX.Value + 10, _startPosY.Value + 40);
|
g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 50, _startPosX.Value, _startPosY.Value + 30);
|
||||||
g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 40, _startPosX.Value + 80, _startPosY.Value + 40);
|
g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 30, _startPosX.Value + 70, _startPosY.Value + 30);
|
||||||
g.DrawLine(pen, _startPosX.Value + 80, _startPosY.Value + 40, _startPosX.Value + 100, _startPosY.Value + 50);
|
g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value + 30, _startPosX.Value + 90, _startPosY.Value + 40);
|
||||||
g.DrawLine(pen, _startPosX.Value + 80, _startPosY.Value + 60, _startPosX.Value + 100, _startPosY.Value + 50);
|
g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value + 50, _startPosX.Value + 90, _startPosY.Value + 40);
|
||||||
//отрисовка цвета палубы
|
//отрисовка цвета палубы
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 15, _startPosY.Value + 40, 60, 20);
|
g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 30, 60, 20);
|
||||||
/// g.FillEllipse(additionalBrush, _startPosX.Value + 15, _startPosY.Value + 40, 60, 20);
|
|
||||||
|
|
||||||
// отрисовка поплавков
|
// отрисовка поплавков
|
||||||
if (EntityCatamaran.Floats)
|
|
||||||
{
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 60, _startPosX.Value + 45, _startPosY.Value + 75);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 40, _startPosX.Value + 45, _startPosY.Value + 25);
|
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 0, _startPosY.Value + 75, 100, 15);
|
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 0, _startPosY.Value + 10, 100, 15);
|
|
||||||
|
|
||||||
g.FillEllipse(additionalBrush, _startPosX.Value + 0, _startPosY.Value + 75, 100, 15);
|
|
||||||
g.FillEllipse(additionalBrush, _startPosX.Value + 0, _startPosY.Value + 10, 100, 15);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -4,24 +4,10 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LabOOP_1;
|
namespace Project_Catamaran.Entities;
|
||||||
|
|
||||||
public class EntityCatamaran
|
public class EntityCatamaran : EntitySimpleCatamaran
|
||||||
{
|
{
|
||||||
/// <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>
|
||||||
/// Доп цвет
|
/// Доп цвет
|
||||||
@ -34,19 +20,17 @@ public class EntityCatamaran
|
|||||||
public bool Deck { get; private set; }
|
public bool Deck { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Признак (опция) наличия
|
/// Признак (опция) наличия паруса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Sail { get; private set; }
|
public bool Sail { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Признак (опция) наличия мачты
|
/// Признак (опция) наличия поплавков
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Floats { get; private set; }
|
public bool Floats { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения катамарана
|
|
||||||
/// </summary>
|
|
||||||
public double Step => Speed * 100 / Weight;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация полей объекта-класса катамарана
|
/// Инициализация полей объекта-класса катамарана
|
||||||
@ -58,15 +42,13 @@ public class EntityCatamaran
|
|||||||
/// <param name="deck">Признак наличия палубы</param>
|
/// <param name="deck">Признак наличия палубы</param>
|
||||||
/// <param name="sail">Признак наличия мачты</param>
|
/// <param name="sail">Признак наличия мачты</param>
|
||||||
/// <param name="floats">Признак наличия поплавков</param>
|
/// <param name="floats">Признак наличия поплавков</param>
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool deck, bool sail, bool floats)
|
public EntityCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail, bool deck) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
Deck = deck;
|
Deck = deck;
|
||||||
Sail = sail;
|
Sail = sail;
|
||||||
Floats = floats;
|
Floats = floats;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
52
LabOOP_1/LabOOP_1/Entities/EntitySimpleCatamaran.cs
Normal file
52
LabOOP_1/LabOOP_1/Entities/EntitySimpleCatamaran.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Project_Catamaran.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-сущность Простой Катамаран
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public class EntitySimpleCatamaran
|
||||||
|
{
|
||||||
|
/// <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 EntitySimpleCatamaran(int speed, double weight, Color bodyColor)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
45
LabOOP_1/LabOOP_1/FormCatamaran.Designer.cs
generated
45
LabOOP_1/LabOOP_1/FormCatamaran.Designer.cs
generated
@ -1,7 +1,7 @@
|
|||||||
namespace LabOOP_1
|
namespace Project_Catamaran;
|
||||||
|
|
||||||
|
partial class FormCatamaran
|
||||||
{
|
{
|
||||||
partial class FormCatamaran
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -28,25 +28,26 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
buttonCreate = new Button();
|
buttonCreateSimpleCatamaran = new Button();
|
||||||
buttonLeft = new Button();
|
buttonLeft = new Button();
|
||||||
buttonDown = new Button();
|
buttonDown = new Button();
|
||||||
buttonUp = new Button();
|
buttonUp = new Button();
|
||||||
buttonRight = new Button();
|
buttonRight = new Button();
|
||||||
pictureBoxCatamaran = new PictureBox();
|
pictureBoxCatamaran = new PictureBox();
|
||||||
|
buttonCreateCatamaran = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonCreate
|
// buttonCreateSimpleCatamaran
|
||||||
//
|
//
|
||||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonCreateSimpleCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonCreate.Location = new Point(12, 404);
|
buttonCreateSimpleCatamaran.Location = new Point(12, 404);
|
||||||
buttonCreate.Name = "buttonCreate";
|
buttonCreateSimpleCatamaran.Name = "buttonCreateSimpleCatamaran";
|
||||||
buttonCreate.Size = new Size(112, 34);
|
buttonCreateSimpleCatamaran.Size = new Size(260, 34);
|
||||||
buttonCreate.TabIndex = 1;
|
buttonCreateSimpleCatamaran.TabIndex = 1;
|
||||||
buttonCreate.Text = "Заспавнить";
|
buttonCreateSimpleCatamaran.Text = "Создать простой катамаран";
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
buttonCreateSimpleCatamaran.UseVisualStyleBackColor = true;
|
||||||
buttonCreate.Click += buttonCreate_Click;
|
buttonCreateSimpleCatamaran.Click += buttonCreateSimpleCatamaran_Click;
|
||||||
//
|
//
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
@ -105,16 +106,28 @@
|
|||||||
pictureBoxCatamaran.TabIndex = 6;
|
pictureBoxCatamaran.TabIndex = 6;
|
||||||
pictureBoxCatamaran.TabStop = false;
|
pictureBoxCatamaran.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// buttonCreateCatamaran
|
||||||
|
//
|
||||||
|
buttonCreateCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreateCatamaran.Location = new Point(291, 404);
|
||||||
|
buttonCreateCatamaran.Name = "buttonCreateCatamaran";
|
||||||
|
buttonCreateCatamaran.Size = new Size(202, 34);
|
||||||
|
buttonCreateCatamaran.TabIndex = 7;
|
||||||
|
buttonCreateCatamaran.Text = "Создать катамаран";
|
||||||
|
buttonCreateCatamaran.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateCatamaran.Click += buttonCreateCatamaran_Click;
|
||||||
|
//
|
||||||
// FormCatamaran
|
// FormCatamaran
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(buttonCreateCatamaran);
|
||||||
Controls.Add(buttonRight);
|
Controls.Add(buttonRight);
|
||||||
Controls.Add(buttonUp);
|
Controls.Add(buttonUp);
|
||||||
Controls.Add(buttonDown);
|
Controls.Add(buttonDown);
|
||||||
Controls.Add(buttonLeft);
|
Controls.Add(buttonLeft);
|
||||||
Controls.Add(buttonCreate);
|
Controls.Add(buttonCreateSimpleCatamaran);
|
||||||
Controls.Add(pictureBoxCatamaran);
|
Controls.Add(pictureBoxCatamaran);
|
||||||
Name = "FormCatamaran";
|
Name = "FormCatamaran";
|
||||||
Text = "Катамаран";
|
Text = "Катамаран";
|
||||||
@ -123,11 +136,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private Button buttonCreate;
|
private Button buttonCreateSimpleCatamaran;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private PictureBox pictureBoxCatamaran;
|
private PictureBox pictureBoxCatamaran;
|
||||||
}
|
private Button buttonCreateCatamaran;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using ProjectCatamaran;
|
using Project_Catamaran.Drawnings;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -9,11 +9,11 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace LabOOP_1
|
namespace Project_Catamaran;
|
||||||
|
|
||||||
|
public partial class FormCatamaran : Form
|
||||||
{
|
{
|
||||||
public partial class FormCatamaran : Form
|
private DrawningSimpleCatamaran? _drawningSimpleCatamaran;
|
||||||
{
|
|
||||||
private DrawningCatamaran? _drawningCatamaran;
|
|
||||||
|
|
||||||
public FormCatamaran()
|
public FormCatamaran()
|
||||||
{
|
{
|
||||||
@ -22,14 +22,14 @@ namespace LabOOP_1
|
|||||||
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
if (_drawningCatamaran == null)
|
if (_drawningSimpleCatamaran == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap bmp = new(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
Bitmap bmp = new(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
_drawningCatamaran.DrawTransport(gr);
|
_drawningSimpleCatamaran.DrawTransport(gr);
|
||||||
pictureBoxCatamaran.Image = bmp;
|
pictureBoxCatamaran.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,18 +38,45 @@ namespace LabOOP_1
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
private void CreateObject(string type)
|
||||||
{
|
{
|
||||||
Random random = new();
|
Random random = new();
|
||||||
_drawningCatamaran = new DrawningCatamaran();
|
switch (type)
|
||||||
_drawningCatamaran.Init(random.Next(100, 300), random.Next(1000, 3000),
|
{
|
||||||
|
case nameof(DrawningSimpleCatamaran):
|
||||||
|
_drawningSimpleCatamaran = new DrawningSimpleCatamaran(random.Next(30, 70), random.Next(100, 500),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||||
|
break;
|
||||||
|
case nameof(DrawningCatamaran):
|
||||||
|
_drawningSimpleCatamaran = new DrawningCatamaran(random.Next(30, 70), random.Next(100, 500),
|
||||||
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)));
|
||||||
_drawningCatamaran.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
break;
|
||||||
_drawningCatamaran.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
default:
|
||||||
Draw();
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
_drawningSimpleCatamaran.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||||
|
_drawningSimpleCatamaran.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
|
Draw();
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка кнопки "Создать обычнвй катамаран"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
|
||||||
|
private void buttonCreateSimpleCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSimpleCatamaran));
|
||||||
|
/// <summary>
|
||||||
|
/// Обработка кнопки "Создать катамаран"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
|
||||||
|
private void buttonCreateCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||||
@ -58,7 +85,7 @@ namespace LabOOP_1
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawningCatamaran == null)
|
if (_drawningSimpleCatamaran == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -68,16 +95,16 @@ namespace LabOOP_1
|
|||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case "buttonUp":
|
case "buttonUp":
|
||||||
result = _drawningCatamaran.MoveTransport(DirectionType.Up);
|
result = _drawningSimpleCatamaran.MoveTransport(DirectionType.Up);
|
||||||
break;
|
break;
|
||||||
case "buttonDown":
|
case "buttonDown":
|
||||||
result = _drawningCatamaran.MoveTransport(DirectionType.Down);
|
result = _drawningSimpleCatamaran.MoveTransport(DirectionType.Down);
|
||||||
break;
|
break;
|
||||||
case "buttonLeft":
|
case "buttonLeft":
|
||||||
result = _drawningCatamaran.MoveTransport(DirectionType.Left);
|
result = _drawningSimpleCatamaran.MoveTransport(DirectionType.Left);
|
||||||
break;
|
break;
|
||||||
case "buttonRight":
|
case "buttonRight":
|
||||||
result = _drawningCatamaran.MoveTransport(DirectionType.Right);
|
result = _drawningSimpleCatamaran.MoveTransport(DirectionType.Right);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +113,5 @@ namespace LabOOP_1
|
|||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace LabOOP_1
|
namespace Project_Catamaran;
|
||||||
|
|
||||||
|
internal static class Program
|
||||||
{
|
{
|
||||||
internal static class Program
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -13,5 +13,4 @@ namespace LabOOP_1
|
|||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormCatamaran());
|
Application.Run(new FormCatamaran());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,7 +8,7 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace LabOOP_1.Properties {
|
namespace Project_Catamaran.Properties {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace LabOOP_1.Properties {
|
|||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LabOOP_1.Properties.Resources", typeof(Resources).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Project_Catamaran.Properties.Resources", typeof(Resources).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.8.34322.80
|
VisualStudioVersion = 17.8.34322.80
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabOOP_1", "LabOOP_1\LabOOP_1.csproj", "{0DC6AC2D-A965-444A-8795-FFA43F376E96}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Project Catamaran", "LabOOP_1\Project Catamaran.csproj", "{0DC6AC2D-A965-444A-8795-FFA43F376E96}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Loading…
Reference in New Issue
Block a user