From 8c7e0c3e99861f5459038868598dfa979850be61 Mon Sep 17 00:00:00 2001 From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com> Date: Thu, 12 Oct 2023 21:23:15 +0400 Subject: [PATCH 1/6] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE=D0=B2=20=D0=B8=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RPP_FirstLaba_Tractor/DirectionType.cs | 29 +++ .../RPP_FirstLaba_Tractor/DrawingTractor.cs | 180 ++++++++++++++++++ .../RPP_FirstLaba_Tractor/Form1.Designer.cs | 39 ---- .../RPP_FirstLaba_Tractor/Form1.cs | 10 - .../RPP_FirstLaba_Tractor/FormTractor.cs | 109 +++++++++++ .../RPP_FirstLaba_Tractor/FormTractor.resx | 60 ++++++ .../RPP_FirstLaba_Tractor/Program.cs | 2 +- .../Properties/Resources.Designer.cs | 103 ++++++++++ .../{Form1.resx => Properties/Resources.resx} | 13 ++ .../RPP_FirstLaba_Tractor.csproj | 15 ++ .../RPP_FirstLaba_Tractor/Tractor.cs | 43 +++++ .../RPP_FirstLaba_Tractor/arrowDown.png | Bin 0 -> 17882 bytes .../RPP_FirstLaba_Tractor/arrowLeft.png | Bin 0 -> 17771 bytes .../RPP_FirstLaba_Tractor/arrowRight.png | Bin 0 -> 1365 bytes .../RPP_FirstLaba_Tractor/arrowUp.png | Bin 0 -> 17415 bytes 15 files changed, 553 insertions(+), 50 deletions(-) create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DirectionType.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs delete mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.Designer.cs delete mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.resx create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.Designer.cs rename RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/{Form1.resx => Properties/Resources.resx} (84%) create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowDown.png create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowLeft.png create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowRight.png create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowUp.png diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DirectionType.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DirectionType.cs new file mode 100644 index 0000000..c561ded --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DirectionType.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor +{ + public enum DirectionType + { + /// + /// /// Вверх + /// /// + Up = 1, + /// + /// Вниз + /// + Down = 2, + /// + /// Влево + /// + Left = 3, + /// + /// Вправо + /// + Right = 4 + + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs new file mode 100644 index 0000000..d354f33 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor +{ + internal class DrawningTractor + { + /// + /// Класс-сущность + /// + public EntityTractor? EntityTractor { get; private set; } + /// + /// Ширина окна + /// + private int _pictureWidth; + /// + /// Высота окна + /// + private int _pictureHeight; + /// + /// Левая координата прорисовки автомобиля + /// + private int _startPosX; + /// + /// Верхняя кооридната прорисовки автомобиля + /// + private int _startPosY; + /// + /// Ширина прорисовки автомобиля + /// + private readonly int _tractorWidth = 80; + /// + /// Высота прорисовки автомобиля + /// + private readonly int _tractorHeight = 60; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Цвет кузова + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + /// Ширина картинки + /// Высота картинки + /// true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах + public bool Init(int speed, double weight, Color bodyColor, int width, int height) + { + + _pictureWidth = width; + _pictureHeight = height; + if (_tractorWidth > _pictureHeight || _tractorHeight > _pictureHeight) + { + _pictureWidth = 2 * _tractorWidth; + _pictureHeight = 2 * _tractorHeight; + + } + EntityTractor = new EntityTractor(); + EntityTractor.Init(speed, weight, bodyColor); + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + _startPosX = x; + _startPosY = y; + + if ((x + _tractorWidth > _pictureWidth) || (y + _pictureHeight > _pictureHeight)) + { + Random random = new(); + x = random.Next(0, _pictureWidth); + x = random.Next(0, _pictureHeight); + } + } + /// + /// Изменение направления перемещения + /// + /// Направление + /// + + public void MoveTransport(DirectionType direction) + { + if (EntityTractor == null) + { + return; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX - EntityTractor.Step > 0) + { + _startPosX -= (int)EntityTractor.Step; + } + break; + //вверх + case DirectionType.Up: + if (_startPosY - EntityTractor.Step > 0) + { + _startPosY -= (int)EntityTractor.Step; + } + break; + // вправо + case DirectionType.Right: + if (_startPosX + _tractorWidth + EntityTractor.Step < _pictureWidth) + { + _startPosX += (int)EntityTractor.Step; + } + break; + //вниз + case DirectionType.Down: + if (_startPosY + _tractorHeight + EntityTractor.Step < _pictureHeight) + { + _startPosY += (int)EntityTractor.Step; + } + break; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityTractor == null) + { + return; + } + Pen pen = new(Color.Black); + Brush brGray = new SolidBrush(Color.Gray); + Brush brBlack = new SolidBrush(Color.Black); + Brush additionalBrush = new + SolidBrush(EntityTractor.BodyColor); + + //Гусеницы + g.FillEllipse(brGray, _startPosX, _startPosY + 41, 25, 25); + g.FillEllipse(brGray, _startPosX + 55, _startPosY + 41, 25, 25); + g.FillRectangle(brGray, _startPosX + 13, _startPosY + 41, 54, 25); + //колеса + g.FillEllipse(brBlack, _startPosX, _startPosY + 45, 15, 15); + g.FillEllipse(brBlack, _startPosX + 65, _startPosY + 45, 15, 15); + g.FillEllipse(brBlack, _startPosX + 35, _startPosY + 55, 10, 10); + g.FillEllipse(brBlack, _startPosX + 20, _startPosY + 55, 10, 10); + g.FillEllipse(brBlack, _startPosX + 50, _startPosY + 55, 10, 10); + g.FillEllipse(brBlack, _startPosX + 25, _startPosY + 40, 10, 10); + g.FillEllipse(brBlack, _startPosX + 45, _startPosY + 40, 10, 10); + //кузов + g.FillRectangle(additionalBrush, _startPosX, _startPosY + 20, 80, 20); + g.FillRectangle(additionalBrush, _startPosX + 60, _startPosY, 10, 20); + g.FillRectangle(additionalBrush, _startPosX, _startPosY, 40, 20); + + //Окно + Brush brBlue = new SolidBrush(Color.Blue); + g.FillRectangle(brBlue, _startPosX + 10, _startPosY + 3, 25, 15); + + //Колеса + g.FillEllipse(additionalBrush, _startPosX + 2, _startPosY + 47, 11, 11); + g.FillEllipse(additionalBrush, _startPosX + 67, _startPosY + 47, 11, 11); + g.FillEllipse(additionalBrush, _startPosX + 37, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 22, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 52, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 27, _startPosY + 42, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 47, _startPosY + 42, 6, 6); + + //границы трактора + g.DrawRectangle(pen, _startPosX, _startPosY + 20, 80, 20); + g.DrawRectangle(pen, _startPosX + 60, _startPosY, 10, 20); + g.DrawRectangle(pen, _startPosX, _startPosY, 40, 20); + } + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.Designer.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.Designer.cs deleted file mode 100644 index 25ca53f..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace RPP_FirstLaba_Tractor -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.cs deleted file mode 100644 index 4f2d728..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace RPP_FirstLaba_Tractor -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs new file mode 100644 index 0000000..da6423d --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs @@ -0,0 +1,109 @@ +namespace RPP_FirstLaba_Tractor +{ + public partial class FormTractor : Form + { + private Button buttonTop; + private Button buttonLeft; + private Button buttonDown; + private Button buttonRight; + private Button buttonCreate; + private PictureBox pictureBoxTractor; + + public FormTractor() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + this.pictureBoxTractor = new System.Windows.Forms.PictureBox(); + this.buttonTop = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonCreate = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).BeginInit(); + this.SuspendLayout(); + // + // pictureBoxTractor + // + this.pictureBoxTractor.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxTractor.Location = new System.Drawing.Point(0, 0); + this.pictureBoxTractor.Name = "pictureBoxTractor"; + this.pictureBoxTractor.Size = new System.Drawing.Size(882, 453); + this.pictureBoxTractor.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxTractor.TabIndex = 0; + this.pictureBoxTractor.TabStop = false; + // + // buttonTop + // + this.buttonTop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonTop.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowUp; + this.buttonTop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonTop.Location = new System.Drawing.Point(804, 376); + this.buttonTop.Name = "buttonTop"; + this.buttonTop.Size = new System.Drawing.Size(30, 30); + this.buttonTop.TabIndex = 1; + this.buttonTop.UseVisualStyleBackColor = true; + // + // buttonLeft + // + this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonLeft.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowLeft; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonLeft.Location = new System.Drawing.Point(768, 411); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(30, 30); + this.buttonLeft.TabIndex = 2; + this.buttonLeft.UseVisualStyleBackColor = true; + // + // buttonDown + // + this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDown.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowDown; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonDown.Location = new System.Drawing.Point(804, 411); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(30, 30); + this.buttonDown.TabIndex = 3; + this.buttonDown.UseVisualStyleBackColor = true; + // + // buttonRight + // + this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRight.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowRight; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.buttonRight.Location = new System.Drawing.Point(840, 411); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(30, 30); + this.buttonRight.TabIndex = 4; + this.buttonRight.UseVisualStyleBackColor = true; + // + // buttonCreate + // + this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreate.Location = new System.Drawing.Point(12, 412); + this.buttonCreate.Name = "buttonCreate"; + this.buttonCreate.Size = new System.Drawing.Size(94, 29); + this.buttonCreate.TabIndex = 5; + this.buttonCreate.Text = ""; + this.buttonCreate.UseVisualStyleBackColor = true; + // + // FormTractor + // + this.ClientSize = new System.Drawing.Size(882, 453); + this.Controls.Add(this.buttonCreate); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.buttonDown); + this.Controls.Add(this.buttonLeft); + this.Controls.Add(this.buttonTop); + this.Controls.Add(this.pictureBoxTractor); + this.Name = "FormTractor"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + } +} \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.resx b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs index c61cbe8..7556447 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs @@ -11,7 +11,7 @@ namespace RPP_FirstLaba_Tractor // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new FormTractor()); } } } \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.Designer.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.Designer.cs new file mode 100644 index 0000000..86bf022 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace RPP_FirstLaba_Tractor.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RPP_FirstLaba_Tractor.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowDown { + get { + object obj = ResourceManager.GetObject("arrowDown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowLeft { + get { + object obj = ResourceManager.GetObject("arrowLeft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowRight { + get { + object obj = ResourceManager.GetObject("arrowRight", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowUp { + get { + object obj = ResourceManager.GetObject("arrowUp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.resx b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.resx similarity index 84% rename from RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.resx rename to RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.resx index 1af7de1..55894d3 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Form1.resx +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.csproj b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.csproj index b57c89e..13ee123 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.csproj +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs new file mode 100644 index 0000000..843b95c --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor +{ + public class EntityTractor + { + /// + /// Скорость + /// + public int Speed { get; private set; } + /// + /// Вес + /// + public double Weight { get; private set; } + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + + public double Step => (double)Speed * 100 / Weight; + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + public void Init(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } + + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowDown.png b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowDown.png new file mode 100644 index 0000000000000000000000000000000000000000..6bc5f35a104da5b845d0403290652354c73844d1 GIT binary patch literal 17882 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%0AnyE zXXAZT=hUn*N|!ge77^CFM;jMW>b$y{;9LZ=u_TNvY3l w8>=J_BMO*R+pTwQH&S(#5e`&5tsR7FvTPtVe&{-*`R^-kE}qT@9K)6W1ym>-jsO4v literal 0 HcmV?d00001 diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowLeft.png b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..71da8a325bf2f36827e6411505727a699d6a1b0b GIT binary patch literal 17771 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 literal 0 HcmV?d00001 diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowRight.png b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowRight.png new file mode 100644 index 0000000000000000000000000000000000000000..69bd44fa391f5ac37065270141500283b73c7ac7 GIT binary patch literal 1365 zcmX9;ZBSE36b%7ILP!F&5a}Zcm;g44s4!4SAjx}tgi#cAL`#FhK#ip$$O8gVBw~_> z6oe>)wIdLOsSYK6R6rwN0!p=wn4aHq^TIh2q-=ucB79p}=7Z;twJ3998}EK|*Po{edvI}leFuZx@8K{}erJWHKO z4d`>}liut-llJh`q1oEX2MVn7GulGm9w6 z9gCna4y_ejk7w!A z1IdznI$eLgBmllHZ!(P(%t@3Z0XDC`Bs+T`SazdAx)o|o?ian%Xl5e+wiT}o`I@C) zrdbO+v6HYzJzZ#nq+XlF5`$x;toMIfvNntb*vNlQId7;y5?kGo^u2jk(bELOy7Cll z5z!D@pW;*7PBf%89>7d~kI*S^fn`^c3~TQGCOmM6%L#S!K%`ZO^s>OhFNd@VtYT5C zK%*>kMRa^Jc>#*av4JV<16bSRU_37aYwDgx6KyVy$F6yL4~vGza-7xa3brGzhfcvJ zd#pqXyg0WAMlS8VoDSqS`dhQCXas|>P+GO((s)sFnUol2ukp2tVWl;hv>P+xv^eD- z7;}hu4eY?~bn^r<`Rc{Um~T!0>R6vDUcciSw{C!B3(1$&z2y!D!yj-Yww~Y8CmImA zs3=6JN}y3uNYEH#xq6la9a6BV?JXrdi_wp0=yx#)71(6uK?dGa>h^0T7jR9o8$(^y81O=pR=) z&*WU^ zqjH3dB~6A;Vl$BfCa~rrd9;H7f1r8qs=hTjzRyMx)Gs?iwtuEz?8)Hl({ms2=hNrm zzd7vwkJ-}Mh8K1w$KV4uZubBakEB#!b>`CD@)HFz!SEsalT3~U0!l@I2n6000lz>% zk`i!@1b$Zmh3_uJ6}jE4q1>pr@~*2w+3{NSN>}PhYya(-{|g!UOaY}77}^48%7CaE zGL`Q@mH5nGK})95xSHMXC+5fBE19sX)qRB+vus7j@{m=Gd>59{oiXRlgLn3TOFa8f z=H%mP^w(*WlW{_OdPHkJ@`q1+*m!}ll>?5 z;|@#c0k?L8t#QwNVJ9FCa}BOT-!izl9W}H1QR+)&Y&U4Xfd_BoS=c;S#|^M}eFW{S zE}Dsw2lC)`&wOE859ov6LV^Y*@l#phM^E$Pr;5tHlVK6Kk5pwW?lNhb z3=_*R$>A%*ACCnVGBgkF3j41h0&tkITFMX Kv5-!*@A&`QD|Z|K literal 0 HcmV?d00001 diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowUp.png b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/arrowUp.png new file mode 100644 index 0000000000000000000000000000000000000000..47c62f6685bc9cbd481a2bf90277b643c72c5ce9 GIT binary patch literal 17415 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 W3R(F}ff{-z13cV)+>T5OQ~d}1Qj6~Z literal 0 HcmV?d00001 -- 2.25.1 From 0d0d57578e1e3774ce82450346f23c735fac6ee5 Mon Sep 17 00:00:00 2001 From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com> Date: Thu, 12 Oct 2023 21:25:26 +0400 Subject: [PATCH 2/6] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RPP_FirstLaba_Tractor/FormTractor.cs | 145 ++++++++++++++---- 1 file changed, 116 insertions(+), 29 deletions(-) diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs index da6423d..2a7e443 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs @@ -1,27 +1,109 @@ namespace RPP_FirstLaba_Tractor { + /// + /// " " + /// public partial class FormTractor : Form { + private PictureBox pictureBoxTractor; + private Button buttonCreate; private Button buttonTop; private Button buttonLeft; private Button buttonDown; private Button buttonRight; - private Button buttonCreate; - private PictureBox pictureBoxTractor; + public int getPictureWidth() + { + return pictureBoxTractor.Width; + } + public int getPictureHeight() + { + return pictureBoxTractor.Height; + } + + /// + /// - + /// + private DrawningTractor? _drawningTractor; + /// + /// + /// public FormTractor() { InitializeComponent(); } + /// + /// + /// + private void Draw() + { + if (_drawningTractor == null) + { + return; + } + Bitmap bmp = new(pictureBoxTractor.Width, + pictureBoxTractor.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningTractor.DrawTransport(gr); + pictureBoxTractor.Image = bmp; + } + /// + /// "" + /// + /// + /// + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningTractor = new DrawningTractor(); + _drawningTractor.Init(random.Next(100, 300), + random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), + random.Next(0, 256)), + pictureBoxTractor.Width, pictureBoxTractor.Height); + _drawningTractor.SetPosition(random.Next(10, 100), + random.Next(10, 100)); + Draw(); + } + + /// + /// + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawningTractor == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonTop": + _drawningTractor.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawningTractor.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawningTractor.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawningTractor.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } private void InitializeComponent() { this.pictureBoxTractor = new System.Windows.Forms.PictureBox(); + this.buttonCreate = new System.Windows.Forms.Button(); this.buttonTop = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); - this.buttonCreate = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).BeginInit(); this.SuspendLayout(); // @@ -30,80 +112,85 @@ namespace RPP_FirstLaba_Tractor this.pictureBoxTractor.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBoxTractor.Location = new System.Drawing.Point(0, 0); this.pictureBoxTractor.Name = "pictureBoxTractor"; - this.pictureBoxTractor.Size = new System.Drawing.Size(882, 453); + this.pictureBoxTractor.Size = new System.Drawing.Size(891, 490); this.pictureBoxTractor.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxTractor.TabIndex = 0; this.pictureBoxTractor.TabStop = false; // + // buttonCreate + // + this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreate.Location = new System.Drawing.Point(12, 440); + this.buttonCreate.Name = "buttonCreate"; + this.buttonCreate.Size = new System.Drawing.Size(94, 29); + this.buttonCreate.TabIndex = 1; + this.buttonCreate.Text = ""; + this.buttonCreate.UseVisualStyleBackColor = true; + this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); + // // buttonTop // this.buttonTop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonTop.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowUp; - this.buttonTop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonTop.Location = new System.Drawing.Point(804, 376); + this.buttonTop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonTop.Location = new System.Drawing.Point(813, 412); this.buttonTop.Name = "buttonTop"; this.buttonTop.Size = new System.Drawing.Size(30, 30); - this.buttonTop.TabIndex = 1; + this.buttonTop.TabIndex = 2; this.buttonTop.UseVisualStyleBackColor = true; + this.buttonTop.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonLeft // this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowLeft; - this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonLeft.Location = new System.Drawing.Point(768, 411); + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonLeft.Location = new System.Drawing.Point(777, 448); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(30, 30); - this.buttonLeft.TabIndex = 2; + this.buttonLeft.TabIndex = 3; this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonDown // this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowDown; - this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonDown.Location = new System.Drawing.Point(804, 411); + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonDown.Location = new System.Drawing.Point(813, 448); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(30, 30); - this.buttonDown.TabIndex = 3; + this.buttonDown.TabIndex = 4; this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonRight // this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowRight; - this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonRight.Location = new System.Drawing.Point(840, 411); + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonRight.Location = new System.Drawing.Point(849, 448); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(30, 30); - this.buttonRight.TabIndex = 4; + this.buttonRight.TabIndex = 5; this.buttonRight.UseVisualStyleBackColor = true; - // - // buttonCreate - // - this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreate.Location = new System.Drawing.Point(12, 412); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(94, 29); - this.buttonCreate.TabIndex = 5; - this.buttonCreate.Text = ""; - this.buttonCreate.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); // // FormTractor // - this.ClientSize = new System.Drawing.Size(882, 453); - this.Controls.Add(this.buttonCreate); + this.ClientSize = new System.Drawing.Size(891, 490); this.Controls.Add(this.buttonRight); this.Controls.Add(this.buttonDown); this.Controls.Add(this.buttonLeft); this.Controls.Add(this.buttonTop); + this.Controls.Add(this.buttonCreate); this.Controls.Add(this.pictureBoxTractor); this.Name = "FormTractor"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } + } } \ No newline at end of file -- 2.25.1 From b6e2b792972b256a3269faebfd0836bdc7fb924e Mon Sep 17 00:00:00 2001 From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com> Date: Thu, 26 Oct 2023 14:35:36 +0400 Subject: [PATCH 3/6] =?UTF-8?q?=D0=A1=D0=9C=D0=AD=D0=A0=D0=A2=D0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RPP_FirstLaba_Tractor/AbstractStrategy.cs | 136 +++++++++++ .../RPP_FirstLaba_Tractor/BuldoserTractor.cs | 51 +++++ .../DrawingBuldoserTractor.cs | 116 ++++++++++ .../DrawingObjectTractor.cs | 37 +++ .../RPP_FirstLaba_Tractor/DrawingTractor.cs | 215 ++++++++++-------- .../RPP_FirstLaba_Tractor/FormTractor.cs | 133 +++++++++-- .../RPP_FirstLaba_Tractor/IMoveableObject.cs | 36 +++ .../RPP_FirstLaba_Tractor/MoveToBorder.cs | 41 ++++ .../RPP_FirstLaba_Tractor/MoveToCenter.cs | 57 +++++ .../RPP_FirstLaba_Tractor/ObjectParameters.cs | 57 +++++ .../RPP_FirstLaba_Tractor/Status.cs | 18 ++ .../RPP_FirstLaba_Tractor/Tractor.cs | 66 +++--- 12 files changed, 827 insertions(+), 136 deletions(-) create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/BuldoserTractor.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingBuldoserTractor.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingObjectTractor.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs new file mode 100644 index 0000000..c67d5af --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RPP_FirstLaba_Tractor.DrawningObjects; + +namespace RPP_FirstLaba_Tractor.MovementStrategy +{ + /// + /// Класс-стратегия перемещения объекта + /// + public abstract class AbstractStrategy + { + /// + /// Перемещаемый объект + /// + private IMoveableObject? _moveableObject; + /// + /// Статус перемещения + /// + private Status _state = Status.NotInit; + /// + /// Ширина поля + /// + protected int FieldWidth { get; private set; } + /// + /// Высота поля + /// + protected int FieldHeight { get; private set; } + /// + /// Статус перемещения + /// + public Status GetStatus() { return _state; } + /// + /// Установка данных + /// + /// Перемещаемый объект + /// Ширина поля + /// Высота поля + public void SetData(IMoveableObject moveableObject, int width, int + height) + { + if (moveableObject == null) + { + _state = Status.NotInit; + return; + } + _state = Status.InProgress; + _moveableObject = moveableObject; + FieldWidth = width; + FieldHeight = height; + } + /// + /// Шаг перемещения + /// + public void MakeStep() + { + if (_state != Status.InProgress) + { + return; + } + if (IsTargetDestinaion()) + { + _state = Status.Finish; + return; + } + MoveToTarget(); + } + /// + /// Перемещение влево + /// + /// Результат перемещения (true - удалось переместиться, false -неудача) + protected bool MoveLeft() => MoveTo(DirectionType.Left); + /// + /// Перемещение вправо + /// + /// Результат перемещения (true - удалось переместиться,false - неудача) + protected bool MoveRight() => MoveTo(DirectionType.Right); + /// + /// Перемещение вверх + /// + /// Результат перемещения (true - удалось переместиться,false - неудача) + protected bool MoveUp() => MoveTo(DirectionType.Up); + /// + /// Перемещение вниз + /// + /// Результат перемещения (true - удалось переместиться,false - неудача) + protected bool MoveDown() => MoveTo(DirectionType.Down); + /// + /// Параметры объекта + /// + protected ObjectParameters? GetObjectParameters => + _moveableObject?.GetObjectPosition; + /// + /// Шаг объекта + /// + /// + protected int? GetStep() + { + if (_state != Status.InProgress) + { + return null; + } + return _moveableObject?.GetStep; + } + /// + /// Перемещение к цели + /// + protected abstract void MoveToTarget(); + /// + /// Достигнута ли цель + /// + /// + protected abstract bool IsTargetDestinaion(); + /// + /// Попытка перемещения в требуемом направлении + /// + /// Направление + /// Результат попытки (true - удалось переместиться, false -неудача) + private bool MoveTo(DirectionType directionType) + { + if (_state != Status.InProgress) + { + return false; + } + if (_moveableObject?.CheckCanMove(directionType) ?? false) + { + _moveableObject.MoveObject(directionType); + return true; + } + return false; + } + + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/BuldoserTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/BuldoserTractor.cs new file mode 100644 index 0000000..7a8c053 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/BuldoserTractor.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor.Entities +{ + /// + /// Класс-сущность "Спортивный автомобиль" + /// + public class EntityBuldoserTractor : EntityTractor + { + /// + /// Дополнительный цвет (для опциональных элементов) + /// + public Color AdditionalColor { get; private set; } + /// + /// Признак (опция) наличия обвеса + /// + public bool BodyKit { get; private set; } + /// + /// Признак (опция) наличия антикрыла + /// + public bool Wing { get; private set; } + /// + /// Признак (опция) наличия гоночной полосы + /// + public bool SportLine { get; private set; } + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + public EntityBuldoserTractor(int speed, double weight, Color bodyColor, Color + additionalColor, bool bodyKit, bool wing, bool sportLine): + base(speed, weight, bodyColor) + { + AdditionalColor = additionalColor; + BodyKit = bodyKit; + Wing = wing; + SportLine = sportLine; + } + } + +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingBuldoserTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingBuldoserTractor.cs new file mode 100644 index 0000000..9e8326f --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingBuldoserTractor.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RPP_FirstLaba_Tractor.Entities; + +namespace RPP_FirstLaba_Tractor.DrawningObjects +{ + /// + /// Класс, отвечающий за прорисовку и перемещение объекта-сущности + /// + public class DrawningBuldoserTractor : DrawningTractor + { + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + /// Ширина картинки + /// Высота картинки + public DrawningBuldoserTractor(int speed, double weight, Color bodyColor, Color + additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) : + base(speed, weight, bodyColor, width, height, 110, 60) + { + if (EntityTractor != null) + { + EntityTractor = new EntityBuldoserTractor(speed, weight, bodyColor, + additionalColor, bodyKit, wing, sportLine); + } + } + public override void DrawTransport(Graphics g) + { + if (EntityTractor is not EntityBuldoserTractor sportCar) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(sportCar.AdditionalColor); + // обвесы + if (sportCar.BodyKit) + { + g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20); + g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, + 20); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, + 20, 40); + g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, + 15); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, + 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 90, + _startPosY, 20, 20); + g.FillEllipse(additionalBrush, _startPosX + 90, + _startPosY + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 10, 20, 40); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 45, 15, 15); + g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20); + g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20); + g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, + 40); + g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, + 15); + g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, + 14, 15); + g.FillEllipse(additionalBrush, _startPosX, _startPosY, + 20, 20); + g.FillEllipse(additionalBrush, _startPosX, _startPosY + + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX + 1, + _startPosY + 10, 25, 40); + g.FillRectangle(additionalBrush, _startPosX + 5, + _startPosY + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX + 5, + _startPosY + 45, 15, 15); + g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, + 15); + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, + 39, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 1, 40, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 45, 40, 15); + } + base.DrawTransport(g); + // спортивная линия + if (sportCar.SportLine) + { + g.FillRectangle(additionalBrush, _startPosX + 75, + _startPosY + 23, 25, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 23, 35, 15); + g.FillRectangle(additionalBrush, _startPosX + 10, + _startPosY + 23, 20, 15); + } + // крыло + if (sportCar.Wing) + { + g.FillRectangle(additionalBrush, _startPosX, _startPosY + + 5, 10, 50); + g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, + 50); + } + } + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingObjectTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingObjectTractor.cs new file mode 100644 index 0000000..6f2f121 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingObjectTractor.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RPP_FirstLaba_Tractor.DrawningObjects; + +namespace RPP_FirstLaba_Tractor.MovementStrategy +{ +public class DrawingObjectTractor : IMoveableObject + { + private readonly DrawningTractor? _drawningCar = null; + public DrawingObjectTractor(DrawningTractor drawningTractor) + { + _drawningCar = drawningTractor; + } + public ObjectParameters? GetObjectPosition + { + get + { + if (_drawningCar == null || _drawningCar.EntityTractor == + null) + { + return null; + } + return new ObjectParameters(_drawningCar.GetPosX, + _drawningCar.GetPosY, _drawningCar.GetWidth, _drawningCar.GetHeight); + } + } + public int GetStep => (int)(_drawningCar?.EntityTractor?.Step ?? 0); + public bool CheckCanMove(DirectionType direction) => + _drawningCar?.CanMove(direction) ?? false; + public void MoveObject(DirectionType direction) => + _drawningCar?.MoveTransport(direction); + } +} + diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs index d354f33..672a97d 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs @@ -3,15 +3,19 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using RPP_FirstLaba_Tractor.Entities; -namespace RPP_FirstLaba_Tractor +namespace RPP_FirstLaba_Tractor.DrawningObjects { - internal class DrawningTractor + /// + /// Класс, отвечающий за прорисовку и перемещение объекта-сущности + /// + public class DrawningTractor { /// /// Класс-сущность /// - public EntityTractor? EntityTractor { get; private set; } + public EntityTractor? EntityTractor { get; protected set; } /// /// Ширина окна /// @@ -23,46 +27,54 @@ namespace RPP_FirstLaba_Tractor /// /// Левая координата прорисовки автомобиля /// - private int _startPosX; + protected int _startPosX; /// /// Верхняя кооридната прорисовки автомобиля /// - private int _startPosY; + protected int _startPosY; /// /// Ширина прорисовки автомобиля /// - private readonly int _tractorWidth = 80; + protected readonly int _tractorWidth = 100; /// /// Высота прорисовки автомобиля /// - private readonly int _tractorHeight = 60; + protected readonly int _tractorHeight = 55; /// - /// Инициализация свойств + /// Конструктор /// /// Скорость /// Вес - /// Цвет кузова - /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы + /// Основной цвет /// Ширина картинки /// Высота картинки - /// true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах - public bool Init(int speed, double weight, Color bodyColor, int width, int height) + public DrawningTractor(int speed, double weight, Color bodyColor, int + width, int height) { - + // TODO: Продумать проверки _pictureWidth = width; _pictureHeight = height; - if (_tractorWidth > _pictureHeight || _tractorHeight > _pictureHeight) - { - _pictureWidth = 2 * _tractorWidth; - _pictureHeight = 2 * _tractorHeight; - - } - EntityTractor = new EntityTractor(); - EntityTractor.Init(speed, weight, bodyColor); - return true; + EntityTractor = new EntityTractor(speed, weight, bodyColor); + } + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Ширина картинки + /// Высота картинки + /// Ширина прорисовки автомобиля + /// Высота прорисовки автомобиля + protected DrawningTractor(int speed, double weight, Color bodyColor, int + width, int height, int carWidth, int carHeight) + { + // TODO: Продумать проверки + _pictureWidth = width; + _pictureHeight = height; + _tractorWidth = carWidth; + _tractorHeight = carHeight; + EntityTractor = new EntityTractor(speed, weight, bodyColor); } /// /// Установка позиции @@ -71,25 +83,61 @@ namespace RPP_FirstLaba_Tractor /// Координата Y public void SetPosition(int x, int y) { + // TODO: Изменение x, y, если при установке объект выходит заграницы _startPosX = x; _startPosY = y; - - if ((x + _tractorWidth > _pictureWidth) || (y + _pictureHeight > _pictureHeight)) - { - Random random = new(); - x = random.Next(0, _pictureWidth); - x = random.Next(0, _pictureHeight); - } } /// /// Изменение направления перемещения /// /// Направление - /// + /// + /// Координата X объекта + /// + public int GetPosX => _startPosX; + /// + /// Координата Y объекта + /// + public int GetPosY => _startPosY; + /// + /// Ширина объекта + /// + public int GetWidth => _tractorWidth; + /// + /// Высота объекта + /// + public int GetHeight => _tractorHeight; - public void MoveTransport(DirectionType direction) + /// + /// Проверка, что объект может переместится по указанному направлению + /// + /// Направление + /// true - можно переместится по указанномунаправлению + public bool CanMove(DirectionType direction) { if (EntityTractor == null) + { + return false; + } + return direction switch + { + //влево + DirectionType.Left => _startPosX - EntityTractor.Step > 0, + //вверх + DirectionType.Up => _startPosY - EntityTractor.Step > 0, + // вправо + DirectionType.Right => _startPosX + EntityTractor.Step + _tractorWidth < _pictureWidth, + DirectionType.Down => _startPosY + EntityTractor.Step + _tractorHeight < _pictureHeight, + _ => false, + }; + } + /// + /// Изменение направления перемещения + /// + /// Направление + public void MoveTransport(DirectionType direction) + { + if (!CanMove(direction) || EntityTractor == null) { return; } @@ -97,84 +145,73 @@ namespace RPP_FirstLaba_Tractor { //влево case DirectionType.Left: - if (_startPosX - EntityTractor.Step > 0) - { - _startPosX -= (int)EntityTractor.Step; - } + _startPosX -= (int)EntityTractor.Step; break; //вверх case DirectionType.Up: - if (_startPosY - EntityTractor.Step > 0) - { - _startPosY -= (int)EntityTractor.Step; - } + _startPosY -= (int)EntityTractor.Step; break; // вправо case DirectionType.Right: - if (_startPosX + _tractorWidth + EntityTractor.Step < _pictureWidth) - { - _startPosX += (int)EntityTractor.Step; - } + _startPosX += (int)EntityTractor.Step; break; //вниз case DirectionType.Down: - if (_startPosY + _tractorHeight + EntityTractor.Step < _pictureHeight) - { - _startPosY += (int)EntityTractor.Step; - } + _startPosY += (int)EntityTractor.Step; break; } } + /// /// Прорисовка объекта /// /// - public void DrawTransport(Graphics g) + public virtual void DrawTransport(Graphics g) { if (EntityTractor == null) { return; } Pen pen = new(Color.Black); - Brush brGray = new SolidBrush(Color.Gray); - Brush brBlack = new SolidBrush(Color.Black); - Brush additionalBrush = new - SolidBrush(EntityTractor.BodyColor); - - //Гусеницы - g.FillEllipse(brGray, _startPosX, _startPosY + 41, 25, 25); - g.FillEllipse(brGray, _startPosX + 55, _startPosY + 41, 25, 25); - g.FillRectangle(brGray, _startPosX + 13, _startPosY + 41, 54, 25); - //колеса - g.FillEllipse(brBlack, _startPosX, _startPosY + 45, 15, 15); - g.FillEllipse(brBlack, _startPosX + 65, _startPosY + 45, 15, 15); - g.FillEllipse(brBlack, _startPosX + 35, _startPosY + 55, 10, 10); - g.FillEllipse(brBlack, _startPosX + 20, _startPosY + 55, 10, 10); - g.FillEllipse(brBlack, _startPosX + 50, _startPosY + 55, 10, 10); - g.FillEllipse(brBlack, _startPosX + 25, _startPosY + 40, 10, 10); - g.FillEllipse(brBlack, _startPosX + 45, _startPosY + 40, 10, 10); + //границы автомобиля + g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20); + g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); + g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10,30); + g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52); + //задние фары + Brush brRed = new SolidBrush(Color.Red); + g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20); + g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20,20); + //передние фары + Brush brYellow = new SolidBrush(Color.Yellow); + g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20,20); + g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, + 20); //кузов - g.FillRectangle(additionalBrush, _startPosX, _startPosY + 20, 80, 20); - g.FillRectangle(additionalBrush, _startPosX + 60, _startPosY, 10, 20); - g.FillRectangle(additionalBrush, _startPosX, _startPosY, 40, 20); - - //Окно - Brush brBlue = new SolidBrush(Color.Blue); - g.FillRectangle(brBlue, _startPosX + 10, _startPosY + 3, 25, 15); - - //Колеса - g.FillEllipse(additionalBrush, _startPosX + 2, _startPosY + 47, 11, 11); - g.FillEllipse(additionalBrush, _startPosX + 67, _startPosY + 47, 11, 11); - g.FillEllipse(additionalBrush, _startPosX + 37, _startPosY + 57, 6, 6); - g.FillEllipse(additionalBrush, _startPosX + 22, _startPosY + 57, 6, 6); - g.FillEllipse(additionalBrush, _startPosX + 52, _startPosY + 57, 6, 6); - g.FillEllipse(additionalBrush, _startPosX + 27, _startPosY + 42, 6, 6); - g.FillEllipse(additionalBrush, _startPosX + 47, _startPosY + 42, 6, 6); - - //границы трактора - g.DrawRectangle(pen, _startPosX, _startPosY + 20, 80, 20); - g.DrawRectangle(pen, _startPosX + 60, _startPosY, 10, 20); - g.DrawRectangle(pen, _startPosX, _startPosY, 40, 20); + Brush br = new SolidBrush(EntityTractor.BodyColor); + g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30); + g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30); + g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50); + //стекла + Brush brBlue = new SolidBrush(Color.LightBlue); + g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5, + 40); + g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5, + 40); + g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, + 2); + g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, + 2); + //выделяем рамкой крышу + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35, + 40); + g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25, + 30); + g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15, + 30); } } } diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs index 2a7e443..1290570 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs @@ -1,3 +1,6 @@ +using RPP_FirstLaba_Tractor.MovementStrategy; +using RPP_FirstLaba_Tractor.DrawningObjects; + namespace RPP_FirstLaba_Tractor { /// @@ -6,12 +9,20 @@ namespace RPP_FirstLaba_Tractor public partial class FormTractor : Form { private PictureBox pictureBoxTractor; - private Button buttonCreate; + private Button buttonCreateTractor; private Button buttonTop; private Button buttonLeft; private Button buttonDown; + private Button buttonCreateBulldoserTractor; + private Button buttonStep; + private ComboBox comboBoxStrategy; private Button buttonRight; + /// + /// + /// + private AbstractStrategy? _abstractStrategy; + public int getPictureWidth() { return pictureBoxTractor.Width; @@ -55,8 +66,7 @@ namespace RPP_FirstLaba_Tractor private void ButtonCreate_Click(object sender, EventArgs e) { Random random = new(); - _drawningTractor = new DrawningTractor(); - _drawningTractor.Init(random.Next(100, 300), + _drawningTractor = new DrawningTractor(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), @@ -99,11 +109,14 @@ namespace RPP_FirstLaba_Tractor private void InitializeComponent() { this.pictureBoxTractor = new System.Windows.Forms.PictureBox(); - this.buttonCreate = new System.Windows.Forms.Button(); + this.buttonCreateTractor = new System.Windows.Forms.Button(); this.buttonTop = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button(); + this.buttonCreateBulldoserTractor = new System.Windows.Forms.Button(); + this.buttonStep = new System.Windows.Forms.Button(); + this.comboBoxStrategy = new System.Windows.Forms.ComboBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).BeginInit(); this.SuspendLayout(); // @@ -117,16 +130,16 @@ namespace RPP_FirstLaba_Tractor this.pictureBoxTractor.TabIndex = 0; this.pictureBoxTractor.TabStop = false; // - // buttonCreate + // buttonCreateTractor // - this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreate.Location = new System.Drawing.Point(12, 440); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(94, 29); - this.buttonCreate.TabIndex = 1; - this.buttonCreate.Text = ""; - this.buttonCreate.UseVisualStyleBackColor = true; - this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); + this.buttonCreateTractor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreateTractor.Location = new System.Drawing.Point(12, 440); + this.buttonCreateTractor.Name = "buttonCreateTractor"; + this.buttonCreateTractor.Size = new System.Drawing.Size(246, 29); + this.buttonCreateTractor.TabIndex = 1; + this.buttonCreateTractor.Text = " "; + this.buttonCreateTractor.UseVisualStyleBackColor = true; + this.buttonCreateTractor.Click += new System.EventHandler(this.ButtonCreate_Click); // // buttonTop // @@ -176,14 +189,52 @@ namespace RPP_FirstLaba_Tractor this.buttonRight.UseVisualStyleBackColor = true; this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); // + // buttonCreateBulldoserTractor + // + this.buttonCreateBulldoserTractor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreateBulldoserTractor.Location = new System.Drawing.Point(264, 440); + this.buttonCreateBulldoserTractor.Name = "buttonCreateBulldoserTractor"; + this.buttonCreateBulldoserTractor.Size = new System.Drawing.Size(199, 29); + this.buttonCreateBulldoserTractor.TabIndex = 6; + this.buttonCreateBulldoserTractor.Text = " "; + this.buttonCreateBulldoserTractor.UseVisualStyleBackColor = true; + this.buttonCreateBulldoserTractor.Click += new System.EventHandler(this.buttonCreateBulldoserTractor_Click); + // + // buttonStep + // + this.buttonStep.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonStep.Location = new System.Drawing.Point(785, 46); + this.buttonStep.Name = "buttonStep"; + this.buttonStep.Size = new System.Drawing.Size(94, 29); + this.buttonStep.TabIndex = 7; + this.buttonStep.Text = "button2"; + this.buttonStep.UseVisualStyleBackColor = true; + this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click); + // + // comboBoxStrategy + // + this.comboBoxStrategy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.comboBoxStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxStrategy.FormattingEnabled = true; + this.comboBoxStrategy.Items.AddRange(new object[] { + " ", + " "}); + this.comboBoxStrategy.Location = new System.Drawing.Point(728, 12); + this.comboBoxStrategy.Name = "comboBoxStrategy"; + this.comboBoxStrategy.Size = new System.Drawing.Size(151, 28); + this.comboBoxStrategy.TabIndex = 8; + // // FormTractor // this.ClientSize = new System.Drawing.Size(891, 490); + this.Controls.Add(this.comboBoxStrategy); + this.Controls.Add(this.buttonStep); + this.Controls.Add(this.buttonCreateBulldoserTractor); this.Controls.Add(this.buttonRight); this.Controls.Add(this.buttonDown); this.Controls.Add(this.buttonLeft); this.Controls.Add(this.buttonTop); - this.Controls.Add(this.buttonCreate); + this.Controls.Add(this.buttonCreateTractor); this.Controls.Add(this.pictureBoxTractor); this.Name = "FormTractor"; ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).EndInit(); @@ -192,5 +243,59 @@ namespace RPP_FirstLaba_Tractor } + private void buttonCreateBulldoserTractor_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningTractor = new DrawningBuldoserTractor(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)), Convert.ToBoolean(random.Next(0, 2)), + buttonCreateBulldoserTractor.Width, buttonCreateBulldoserTractor.Height); + _drawningTractor.SetPosition(random.Next(10, 100), random.Next(10, + 100)); + Draw(); + + } + + private void buttonStep_Click(object sender, EventArgs e) + { + if (_drawningTractor == null) + { + return; + } + if (comboBoxStrategy.Enabled) + { + _abstractStrategy = comboBoxStrategy.SelectedIndex + switch + { + 0 => new MoveToCenter(), + 1 => new MoveToBorder(), + _ => null, + }; + if (_abstractStrategy == null) + { + return; + } + _abstractStrategy.SetData(new + DrawingObjectTractor(_drawningTractor), pictureBoxTractor.Width, + pictureBoxTractor.Height); + comboBoxStrategy.Enabled = false; + } + if (_abstractStrategy == null) + { + return; + } + _abstractStrategy.MakeStep(); + Draw(); + if (_abstractStrategy.GetStatus() == Status.Finish) + { + comboBoxStrategy.Enabled = true; + _abstractStrategy = null; + } + } } } \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs new file mode 100644 index 0000000..8c19d9c --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +//using RPP_FirstLaba_Tractor.Drawnings; + + +namespace RPP_FirstLaba_Tractor.MovementStrategy +{/// + /// Интерфейс для работы с перемещаемым объектом + /// + public interface IMoveableObject + { + /// + /// Получение координаты X объекта + /// + ObjectParameters? GetObjectPosition { get; } + /// + /// Шаг объекта + /// + int GetStep { get; } + /// + /// Проверка, можно ли переместиться по нужному направлению + /// + /// + /// + bool CheckCanMove(DirectionType direction); + /// + /// Изменение направления пермещения объекта + /// + /// Направление + void MoveObject(DirectionType direction); + } + +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs new file mode 100644 index 0000000..c54ee1e --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor.MovementStrategy +{ + internal class MoveToBorder: AbstractStrategy + { + protected override bool IsTargetDestinaion() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.RightBorder + GetStep() >= FieldWidth && + objParams.DownBorder + GetStep() >= FieldHeight; + } + + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + var diffX = FieldWidth - objParams.RightBorder; + if (diffX > GetStep()) + { + MoveRight(); + } + var diffY = FieldHeight - objParams.DownBorder; + if (diffY > GetStep()) + { + MoveDown(); + } + } + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs new file mode 100644 index 0000000..caa4ba2 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor.MovementStrategy +{ + internal class MoveToCenter: AbstractStrategy + { + protected override bool IsTargetDestinaion() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 && + objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.ObjectMiddleVertical <= FieldHeight / 2 && + objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; + } + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } + } +} + diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs new file mode 100644 index 0000000..66ea7f7 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor +{ + /// + /// Параметры-координаты объекта + /// + public class ObjectParameters + { + private readonly int _x; + private readonly int _y; + private readonly int _width; + private readonly int _height; + /// + /// Левая граница + /// + public int LeftBorder => _x; + /// + /// Верхняя граница + /// + public int TopBorder => _y; + /// + /// Правая граница + /// + public int RightBorder => _x + _width; + /// + /// Нижняя граница + /// + public int DownBorder => _y + _height; + /// + /// Середина объекта + /// + public int ObjectMiddleHorizontal => _x + _width / 2; + /// + /// Середина объекта + /// + public int ObjectMiddleVertical => _y + _height / 2; + /// + /// Конструктор + /// + /// Координата X + /// Координата Y + /// Ширина + /// Высота + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + } + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs new file mode 100644 index 0000000..69d15ec --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor +{ + /// + /// Статус выполнения операции перемещения + /// + public enum Status + { + NotInit, InProgress, + Finish + } + +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs index 843b95c..f7fab51 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs @@ -4,40 +4,40 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor +namespace RPP_FirstLaba_Tractor.Entities; + +/// +/// Класс-сущность "Автомобиль" +/// +public class EntityTractor { - public class EntityTractor + /// + /// Скорость + /// + public int Speed { get; private set; } + /// + /// Вес + /// + public double Weight { get; private set; } + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + /// + /// Шаг перемещения автомобиля + /// + public double Step => (double)Speed * 100 / Weight; + /// + /// Конструктор с параметрами + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + public EntityTractor(int speed, double weight, Color bodyColor) { - /// - /// Скорость - /// - public int Speed { get; private set; } - /// - /// Вес - /// - public double Weight { get; private set; } - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } - - public double Step => (double)Speed * 100 / Weight; - /// - /// Инициализация полей объекта-класса спортивного автомобиля - /// - /// Скорость - /// Вес автомобиля - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы - public void Init(int speed, double weight, Color bodyColor) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; - } - + Speed = speed; + Weight = weight; + BodyColor = bodyColor; } } + -- 2.25.1 From c8f9dead9c2d5ae7c532d0346a985deff2f80682 Mon Sep 17 00:00:00 2001 From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com> Date: Fri, 27 Oct 2023 08:24:37 +0400 Subject: [PATCH 4/6] =?UTF-8?q?=D0=9D=D0=B0=D0=B4=D0=B5=D1=8E=D1=81=D1=8C?= =?UTF-8?q?=20=D0=B2=D1=81=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RPP_FirstLaba_Tractor.sln | 2 +- .../RPP_FirstLaba_Tractor/AbstractStrategy.cs | 5 +- .../DrawingBuldoserTractor.cs | 116 --------- .../DrawingObjectTractor.cs | 37 --- .../RPP_FirstLaba_Tractor/DrawingTractor.cs | 217 ----------------- .../DrawningBulldoser.cs | 98 ++++++++ .../DrawningObjectTractor.cs | 40 +++ .../RPP_FirstLaba_Tractor/DrawningTractor.cs | 229 ++++++++++++++++++ ...{BuldoserTractor.cs => EntityBulldoser.cs} | 27 +-- .../RPP_FirstLaba_Tractor/EntityTractor.cs | 44 ++++ .../RPP_FirstLaba_Tractor/FormTractor.cs | 31 +-- .../RPP_FirstLaba_Tractor/IMoveableObject.cs | 9 +- .../RPP_FirstLaba_Tractor/MoveToBorder.cs | 29 ++- .../RPP_FirstLaba_Tractor/MoveToCenter.cs | 6 +- .../RPP_FirstLaba_Tractor/ObjectParameters.cs | 3 +- .../RPP_FirstLaba_Tractor/Status.cs | 5 +- .../RPP_FirstLaba_Tractor/Tractor.cs | 43 ---- 17 files changed, 473 insertions(+), 468 deletions(-) delete mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingBuldoserTractor.cs delete mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingObjectTractor.cs delete mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningObjectTractor.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs rename RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/{BuldoserTractor.cs => EntityBulldoser.cs} (58%) create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs delete mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln index a1ae33d..f5b346e 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.2.32602.215 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPP_FirstLaba_Tractor", "RPP_FirstLaba_Tractor\RPP_FirstLaba_Tractor.csproj", "{EF413F48-FFBF-4510-BA11-FAEBE7C0142A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RPP_FirstLaba_Tractor", "RPP_FirstLaba_Tractor\RPP_FirstLaba_Tractor.csproj", "{EF413F48-FFBF-4510-BA11-FAEBE7C0142A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs index c67d5af..ac1f0f9 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs @@ -71,7 +71,7 @@ namespace RPP_FirstLaba_Tractor.MovementStrategy /// Перемещение влево /// /// Результат перемещения (true - удалось переместиться, false -неудача) - protected bool MoveLeft() => MoveTo(DirectionType.Left); + protected bool MoveLeft() => MoveTo(DirectionType.Left); /// /// Перемещение вправо /// @@ -131,6 +131,5 @@ namespace RPP_FirstLaba_Tractor.MovementStrategy } return false; } - } -} +} \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingBuldoserTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingBuldoserTractor.cs deleted file mode 100644 index 9e8326f..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingBuldoserTractor.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using RPP_FirstLaba_Tractor.Entities; - -namespace RPP_FirstLaba_Tractor.DrawningObjects -{ - /// - /// Класс, отвечающий за прорисовку и перемещение объекта-сущности - /// - public class DrawningBuldoserTractor : DrawningTractor - { - /// - /// Конструктор - /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы - /// Ширина картинки - /// Высота картинки - public DrawningBuldoserTractor(int speed, double weight, Color bodyColor, Color - additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) : - base(speed, weight, bodyColor, width, height, 110, 60) - { - if (EntityTractor != null) - { - EntityTractor = new EntityBuldoserTractor(speed, weight, bodyColor, - additionalColor, bodyKit, wing, sportLine); - } - } - public override void DrawTransport(Graphics g) - { - if (EntityTractor is not EntityBuldoserTractor sportCar) - { - return; - } - Pen pen = new(Color.Black); - Brush additionalBrush = new - SolidBrush(sportCar.AdditionalColor); - // обвесы - if (sportCar.BodyKit) - { - g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20); - g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, - 20); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, - 20, 40); - g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, - 15); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, - 15, 15); - g.FillEllipse(additionalBrush, _startPosX + 90, - _startPosY, 20, 20); - g.FillEllipse(additionalBrush, _startPosX + 90, - _startPosY + 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 10, 20, 40); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX + 90, - _startPosY + 45, 15, 15); - g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20); - g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20); - g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, - 40); - g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, - 15); - g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, - 14, 15); - g.FillEllipse(additionalBrush, _startPosX, _startPosY, - 20, 20); - g.FillEllipse(additionalBrush, _startPosX, _startPosY + - 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX + 1, - _startPosY + 10, 25, 40); - g.FillRectangle(additionalBrush, _startPosX + 5, - _startPosY + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX + 5, - _startPosY + 45, 15, 15); - g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, - 15); - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, - 39, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 1, 40, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 45, 40, 15); - } - base.DrawTransport(g); - // спортивная линия - if (sportCar.SportLine) - { - g.FillRectangle(additionalBrush, _startPosX + 75, - _startPosY + 23, 25, 15); - g.FillRectangle(additionalBrush, _startPosX + 35, - _startPosY + 23, 35, 15); - g.FillRectangle(additionalBrush, _startPosX + 10, - _startPosY + 23, 20, 15); - } - // крыло - if (sportCar.Wing) - { - g.FillRectangle(additionalBrush, _startPosX, _startPosY - + 5, 10, 50); - g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, - 50); - } - } - } -} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingObjectTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingObjectTractor.cs deleted file mode 100644 index 6f2f121..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingObjectTractor.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using RPP_FirstLaba_Tractor.DrawningObjects; - -namespace RPP_FirstLaba_Tractor.MovementStrategy -{ -public class DrawingObjectTractor : IMoveableObject - { - private readonly DrawningTractor? _drawningCar = null; - public DrawingObjectTractor(DrawningTractor drawningTractor) - { - _drawningCar = drawningTractor; - } - public ObjectParameters? GetObjectPosition - { - get - { - if (_drawningCar == null || _drawningCar.EntityTractor == - null) - { - return null; - } - return new ObjectParameters(_drawningCar.GetPosX, - _drawningCar.GetPosY, _drawningCar.GetWidth, _drawningCar.GetHeight); - } - } - public int GetStep => (int)(_drawningCar?.EntityTractor?.Step ?? 0); - public bool CheckCanMove(DirectionType direction) => - _drawningCar?.CanMove(direction) ?? false; - public void MoveObject(DirectionType direction) => - _drawningCar?.MoveTransport(direction); - } -} - diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs deleted file mode 100644 index 672a97d..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawingTractor.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using RPP_FirstLaba_Tractor.Entities; - -namespace RPP_FirstLaba_Tractor.DrawningObjects -{ - /// - /// Класс, отвечающий за прорисовку и перемещение объекта-сущности - /// - public class DrawningTractor - { - /// - /// Класс-сущность - /// - public EntityTractor? EntityTractor { get; protected set; } - /// - /// Ширина окна - /// - private int _pictureWidth; - /// - /// Высота окна - /// - private int _pictureHeight; - /// - /// Левая координата прорисовки автомобиля - /// - protected int _startPosX; - /// - /// Верхняя кооридната прорисовки автомобиля - /// - protected int _startPosY; - /// - /// Ширина прорисовки автомобиля - /// - protected readonly int _tractorWidth = 100; - /// - /// Высота прорисовки автомобиля - /// - protected readonly int _tractorHeight = 55; - /// - /// Конструктор - /// - /// Скорость - /// Вес - /// Основной цвет - /// Ширина картинки - /// Высота картинки - public DrawningTractor(int speed, double weight, Color bodyColor, int - width, int height) - { - // TODO: Продумать проверки - _pictureWidth = width; - _pictureHeight = height; - EntityTractor = new EntityTractor(speed, weight, bodyColor); - } - /// - /// Конструктор - /// - /// Скорость - /// Вес - /// Основной цвет - /// Ширина картинки - /// Высота картинки - /// Ширина прорисовки автомобиля - /// Высота прорисовки автомобиля - protected DrawningTractor(int speed, double weight, Color bodyColor, int - width, int height, int carWidth, int carHeight) - { - // TODO: Продумать проверки - _pictureWidth = width; - _pictureHeight = height; - _tractorWidth = carWidth; - _tractorHeight = carHeight; - EntityTractor = new EntityTractor(speed, weight, bodyColor); - } - /// - /// Установка позиции - /// - /// Координата X - /// Координата Y - public void SetPosition(int x, int y) - { - // TODO: Изменение x, y, если при установке объект выходит заграницы - _startPosX = x; - _startPosY = y; - } - /// - /// Изменение направления перемещения - /// - /// Направление - /// - /// Координата X объекта - /// - public int GetPosX => _startPosX; - /// - /// Координата Y объекта - /// - public int GetPosY => _startPosY; - /// - /// Ширина объекта - /// - public int GetWidth => _tractorWidth; - /// - /// Высота объекта - /// - public int GetHeight => _tractorHeight; - - /// - /// Проверка, что объект может переместится по указанному направлению - /// - /// Направление - /// true - можно переместится по указанномунаправлению - public bool CanMove(DirectionType direction) - { - if (EntityTractor == null) - { - return false; - } - return direction switch - { - //влево - DirectionType.Left => _startPosX - EntityTractor.Step > 0, - //вверх - DirectionType.Up => _startPosY - EntityTractor.Step > 0, - // вправо - DirectionType.Right => _startPosX + EntityTractor.Step + _tractorWidth < _pictureWidth, - DirectionType.Down => _startPosY + EntityTractor.Step + _tractorHeight < _pictureHeight, - _ => false, - }; - } - /// - /// Изменение направления перемещения - /// - /// Направление - public void MoveTransport(DirectionType direction) - { - if (!CanMove(direction) || EntityTractor == null) - { - return; - } - switch (direction) - { - //влево - case DirectionType.Left: - _startPosX -= (int)EntityTractor.Step; - break; - //вверх - case DirectionType.Up: - _startPosY -= (int)EntityTractor.Step; - break; - // вправо - case DirectionType.Right: - _startPosX += (int)EntityTractor.Step; - break; - //вниз - case DirectionType.Down: - _startPosY += (int)EntityTractor.Step; - break; - } - } - - /// - /// Прорисовка объекта - /// - /// - public virtual void DrawTransport(Graphics g) - { - if (EntityTractor == null) - { - return; - } - Pen pen = new(Color.Black); - //границы автомобиля - g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20); - g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20); - g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); - g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30); - g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10,30); - g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52); - //задние фары - Brush brRed = new SolidBrush(Color.Red); - g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20); - g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20,20); - //передние фары - Brush brYellow = new SolidBrush(Color.Yellow); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20,20); - g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, - 20); - //кузов - Brush br = new SolidBrush(EntityTractor.BodyColor); - g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30); - g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30); - g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50); - //стекла - Brush brBlue = new SolidBrush(Color.LightBlue); - g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5, - 40); - g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5, - 40); - g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, - 2); - g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, - 2); - //выделяем рамкой крышу - g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35, - 40); - g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25, - 30); - g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15, - 30); - } - } -} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs new file mode 100644 index 0000000..f179a96 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RPP_FirstLaba_Tractor.Entities; + +namespace RPP_FirstLaba_Tractor.DrawningObjects +{ + /// + /// Класс, отвечающий за прорисовку и перемещение объекта-сущности + /// + public class DrawningBulldoser : DrawningTractor + { + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия орнамента на колесах + /// Признак наличия отвала + /// Ширина картинки + /// Высота картинки + public DrawningBulldoser(int speed, double weight, Color bodyColor, Color + additionalColor, bool wheelsOrnament, bool blade, int width, int height) : + base(speed, weight, bodyColor, width, height, 110, 60) + { + if (EntityTractor != null) + { + EntityTractor = new EntityBulldoser(speed, weight, bodyColor, + additionalColor, wheelsOrnament, blade); + } + } + public override void DrawTransport(Graphics g) + { + if (EntityTractor is not EntityBulldoser bulldoser) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(bulldoser.AdditionalColor); + + base.DrawTransport(g); + if (bulldoser.WheelsOrnament) + { + g.FillEllipse(additionalBrush, _startPosX + 2, _startPosY + 47, 11, 11); + g.FillEllipse(additionalBrush, _startPosX + 67, _startPosY + 47, 11, 11); + g.FillEllipse(additionalBrush, _startPosX + 37, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 22, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 52, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 27, _startPosY + 42, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 47, _startPosY + 42, 6, 6); + g.DrawLine(pen, _startPosX + 7, _startPosY + 47, _startPosX + 7, _startPosY + 58); + g.DrawLine(pen, _startPosX + 2, _startPosY + 53, _startPosX + 13, _startPosY + 53); + + g.DrawLine(pen, _startPosX + 73, _startPosY + 47, _startPosX + 73, _startPosY + 58); + g.DrawLine(pen, _startPosX + 67, _startPosY + 53, _startPosX + 78, _startPosY + 53); + + g.DrawLine(pen, _startPosX + 40, _startPosY + 57, _startPosX + 40, _startPosY + 62); + g.DrawLine(pen, _startPosX + 37, _startPosY + 60, _startPosX + 43, _startPosY + 60); + + g.DrawLine(pen, _startPosX + 25, _startPosY + 57, _startPosX + 25, _startPosY + 62); + g.DrawLine(pen, _startPosX + 22, _startPosY + 60, _startPosX + 28, _startPosY + 60); + + g.DrawLine(pen, _startPosX + 55, _startPosY + 57, _startPosX + 55, _startPosY + 62); + g.DrawLine(pen, _startPosX + 52, _startPosY + 60, _startPosX + 58, _startPosY + 60); + + g.DrawLine(pen, _startPosX + 30, _startPosY + 42, _startPosX + 30, _startPosY + 48); + g.DrawLine(pen, _startPosX + 27, _startPosY + 45, _startPosX + 33, _startPosY + 45); + + g.DrawLine(pen, _startPosX + 50, _startPosY + 42, _startPosX + 50, _startPosY + 48); + g.DrawLine(pen, _startPosX + 47, _startPosY + 45, _startPosX + 53, _startPosY + 45); + } + // отвал + if (bulldoser.Blade) + { + g.FillRectangle(additionalBrush, _startPosX + 82, _startPosY + 30, 10, 40); + g.FillRectangle(additionalBrush, _startPosX + 82, _startPosY + 60, 40, 10); + + for (int i = 0; i < 15; i++) + { + g.FillRectangle(additionalBrush, _startPosX + 82, _startPosY + 60 - i * 2, 40 - i * 2, 10); + } + + g.FillRectangle(additionalBrush, _startPosX + 50, _startPosY + 25, 10, 10); + + for (int i = 0; i < 16; i++) + { + g.FillRectangle(additionalBrush, _startPosX + 50 + i * 2, _startPosY + 25 + i, 10, 10); + } + } + } + + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningObjectTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningObjectTractor.cs new file mode 100644 index 0000000..969c4ee --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningObjectTractor.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RPP_FirstLaba_Tractor.DrawningObjects; + +namespace RPP_FirstLaba_Tractor.MovementStrategy +{ + /// + /// Реализация интерфейса IDrawningObject для работы с объектом DrawningTractor(паттерн Adapter) + /// + public class DrawningObjectTractor : IMoveableObject + { + private readonly DrawningTractor? _drawningTractor = null; + public DrawningObjectTractor(DrawningTractor drawningTractor) + { + _drawningTractor = drawningTractor; + } + public ObjectParameters? GetObjectPosition + { + get + { + if (_drawningTractor == null || _drawningTractor.EntityTractor == + null) + { + return null; + } + return new ObjectParameters(_drawningTractor.GetPosX, + _drawningTractor.GetPosY, _drawningTractor.GetWidth, _drawningTractor.GetHeight); + } + } + public int GetStep => (int)(_drawningTractor?.EntityTractor?.Step ?? 0); + public bool CheckCanMove(DirectionType direction) => + _drawningTractor?.CanMove(direction) ?? false; + public void MoveObject(DirectionType direction) => + _drawningTractor?.MoveTransport(direction); + } + +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs new file mode 100644 index 0000000..a888485 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs @@ -0,0 +1,229 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RPP_FirstLaba_Tractor.Entities; + +namespace RPP_FirstLaba_Tractor.DrawningObjects { + +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// + public class DrawningTractor +{ + /// + /// Класс-сущность + /// + public EntityTractor? EntityTractor { get; protected set; } + /// + /// Ширина окна + /// + private int _pictureWidth; + /// + /// Высота окна + /// + private int _pictureHeight; + /// + /// Левая координата прорисовки автомобиля + /// + protected int _startPosX; + /// + /// Верхняя кооридната прорисовки автомобиля + /// + protected int _startPosY; + /// + /// Ширина прорисовки автомобиля + /// + protected readonly int _tractorWidth = 75; + /// + /// Высота прорисовки автомобиля + /// + protected readonly int _tractorHeight = 60; + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Ширина картинки + /// Высота картинки + public DrawningTractor(int speed, double weight, Color bodyColor, int + width, int height) + { + if (width <= _tractorWidth || height <= _tractorHeight) + return; + _pictureWidth = width; + _pictureHeight = height; + EntityTractor = new EntityTractor(speed, weight, bodyColor); + } + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Ширина картинки + /// Высота картинки + /// Ширина прорисовки автомобиля + /// Высота прорисовки автомобиля + protected DrawningTractor(int speed, double weight, Color bodyColor, int + width, int height, int tractorWidth, int tractorHeight) + { + if (width <= _tractorWidth || height <= _tractorHeight) + return; + _pictureWidth = width; + _pictureHeight = height; + _tractorWidth = tractorWidth; + _tractorHeight = tractorHeight; + EntityTractor = new EntityTractor(speed, weight, bodyColor); + } + + + /// + /// Координата X объекта + /// + public int GetPosX => _startPosX; + /// + /// Координата Y объекта + /// + public int GetPosY => _startPosY; + /// + /// Ширина объекта + /// + public int GetWidth => _tractorWidth; + /// + /// Высота объекта + /// + public int GetHeight => _tractorHeight; + /// + /// Проверка, что объект может переместится по указанному направлению + /// + /// Направление + /// true - можно переместится по указанномнаправлению + public bool CanMove(DirectionType direction) + { + if (EntityTractor == null) + { + return false; + } + return direction switch + { + //влево + DirectionType.Left => _startPosX - EntityTractor.Step > 0, + //вверх + DirectionType.Up => _startPosY - EntityTractor.Step > 0, + // вправо + DirectionType.Right => _startPosX + EntityTractor.Step + _tractorWidth < _pictureWidth, + //вниз + DirectionType.Down => _startPosY + EntityTractor.Step + _tractorHeight < _pictureHeight, + _ => false, + }; + } + /// + /// Изменение направления перемещения + /// + /// Направление + public void MoveTransport(DirectionType direction) + { + if (!CanMove(direction) || EntityTractor == null) + { + return; + } + switch (direction) + { + //влево + case DirectionType.Left: + _startPosX -= (int)EntityTractor.Step; + break; + //вверх + case DirectionType.Up: + _startPosY -= (int)EntityTractor.Step; + break; + // вправо + case DirectionType.Right: + _startPosX += (int)EntityTractor.Step; + break; + //вниз + case DirectionType.Down: + _startPosY += (int)EntityTractor.Step; + break; + } + } + + + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (EntityTractor == null) + return; + _startPosX = x; + _startPosY = y; + if (x + _tractorWidth >= _pictureWidth || y + _tractorHeight >= _pictureHeight) + { + _startPosX = 1; + _startPosY = (_tractorHeight + _tractorHeight) / 2; + } + } + + /// + /// Прорисовка объекта + /// + /// + public virtual void DrawTransport(Graphics g) + { + if (EntityTractor == null) + { + return; + } + Pen pen = new(Color.Black); + Brush brGray = new SolidBrush(Color.Gray); + Brush brBlack = new SolidBrush(Color.Black); + Brush additionalBrush = new + SolidBrush(EntityTractor.BodyColor); + + //Гусеницы + g.FillEllipse(brGray, _startPosX, _startPosY + 41, 25, 25); + g.FillEllipse(brGray, _startPosX + 55, _startPosY + 41, 25, 25); + g.FillRectangle(brGray, _startPosX + 13, _startPosY + 41, 54, 25); + //колеса + g.FillEllipse(brBlack, _startPosX, _startPosY + 45, 15, 15); + g.FillEllipse(brBlack, _startPosX + 65, _startPosY + 45, 15, 15); + g.FillEllipse(brBlack, _startPosX + 35, _startPosY + 55, 10, 10); + g.FillEllipse(brBlack, _startPosX + 20, _startPosY + 55, 10, 10); + g.FillEllipse(brBlack, _startPosX + 50, _startPosY + 55, 10, 10); + g.FillEllipse(brBlack, _startPosX + 25, _startPosY + 40, 10, 10); + g.FillEllipse(brBlack, _startPosX + 45, _startPosY + 40, 10, 10); + //кузов + g.FillRectangle(additionalBrush, _startPosX, _startPosY + 20, 80, 20); + g.FillRectangle(additionalBrush, _startPosX + 60, _startPosY, 10, 20); + g.FillRectangle(additionalBrush, _startPosX, _startPosY, 40, 20); + + //Окно + Brush brBlue = new SolidBrush(Color.Blue); + g.FillRectangle(brBlue, _startPosX + 10, _startPosY + 3, 25, 15); + + //Колеса + g.FillEllipse(additionalBrush, _startPosX + 2, _startPosY + 47, 11, 11); + g.FillEllipse(additionalBrush, _startPosX + 67, _startPosY + 47, 11, 11); + g.FillEllipse(additionalBrush, _startPosX + 37, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 22, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 52, _startPosY + 57, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 27, _startPosY + 42, 6, 6); + g.FillEllipse(additionalBrush, _startPosX + 47, _startPosY + 42, 6, 6); + + //границы трактора + g.DrawRectangle(pen, _startPosX, _startPosY + 20, 80, 20); + g.DrawRectangle(pen, _startPosX + 60, _startPosY, 10, 20); + g.DrawRectangle(pen, _startPosX, _startPosY, 40, 20); + } +} +} + + + + diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/BuldoserTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs similarity index 58% rename from RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/BuldoserTractor.cs rename to RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs index 7a8c053..29be4a0 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/BuldoserTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs @@ -9,7 +9,7 @@ namespace RPP_FirstLaba_Tractor.Entities /// /// Класс-сущность "Спортивный автомобиль" /// - public class EntityBuldoserTractor : EntityTractor + public class EntityBulldoser : EntityTractor { /// /// Дополнительный цвет (для опциональных элементов) @@ -18,15 +18,12 @@ namespace RPP_FirstLaba_Tractor.Entities /// /// Признак (опция) наличия обвеса /// - public bool BodyKit { get; private set; } + public bool WheelsOrnament { get; private set; } /// /// Признак (опция) наличия антикрыла /// - public bool Wing { get; private set; } - /// - /// Признак (опция) наличия гоночной полосы - /// - public bool SportLine { get; private set; } + public bool Blade { get; private set; } + /// /// Инициализация полей объекта-класса спортивного автомобиля /// @@ -34,17 +31,15 @@ namespace RPP_FirstLaba_Tractor.Entities /// Вес автомобиля /// Основной цвет /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы - public EntityBuldoserTractor(int speed, double weight, Color bodyColor, Color - additionalColor, bool bodyKit, bool wing, bool sportLine): - base(speed, weight, bodyColor) + /// Признак наличия обвеса + /// Признак наличия отвала + + public EntityBulldoser(int speed, double weight, Color bodyColor, Color + additionalColor, bool wheelsOrnament, bool blade) : base(speed, weight, bodyColor) { AdditionalColor = additionalColor; - BodyKit = bodyKit; - Wing = wing; - SportLine = sportLine; + WheelsOrnament = wheelsOrnament; + Blade = blade; } } diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs new file mode 100644 index 0000000..8a7e41a --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RPP_FirstLaba_Tractor.Entities +{ + /// + /// Класс-сущность "Автомобиль" + /// + public class EntityTractor + { + /// + /// Скорость + /// + public int Speed { get; private set; } + /// + /// Вес + /// + public double Weight { get; private set; } + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + /// + /// Шаг перемещения автомобиля + /// + public double Step => (double)Speed * 100 / Weight; + /// + /// Конструктор с параметрами + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + public EntityTractor(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } + + } +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs index 1290570..551ed9f 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs @@ -1,3 +1,4 @@ + using RPP_FirstLaba_Tractor.MovementStrategy; using RPP_FirstLaba_Tractor.DrawningObjects; @@ -125,7 +126,7 @@ namespace RPP_FirstLaba_Tractor this.pictureBoxTractor.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBoxTractor.Location = new System.Drawing.Point(0, 0); this.pictureBoxTractor.Name = "pictureBoxTractor"; - this.pictureBoxTractor.Size = new System.Drawing.Size(891, 490); + this.pictureBoxTractor.Size = new System.Drawing.Size(882, 453); this.pictureBoxTractor.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxTractor.TabIndex = 0; this.pictureBoxTractor.TabStop = false; @@ -133,7 +134,7 @@ namespace RPP_FirstLaba_Tractor // buttonCreateTractor // this.buttonCreateTractor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreateTractor.Location = new System.Drawing.Point(12, 440); + this.buttonCreateTractor.Location = new System.Drawing.Point(12, 403); this.buttonCreateTractor.Name = "buttonCreateTractor"; this.buttonCreateTractor.Size = new System.Drawing.Size(246, 29); this.buttonCreateTractor.TabIndex = 1; @@ -146,7 +147,7 @@ namespace RPP_FirstLaba_Tractor this.buttonTop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonTop.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowUp; this.buttonTop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonTop.Location = new System.Drawing.Point(813, 412); + this.buttonTop.Location = new System.Drawing.Point(804, 375); this.buttonTop.Name = "buttonTop"; this.buttonTop.Size = new System.Drawing.Size(30, 30); this.buttonTop.TabIndex = 2; @@ -158,7 +159,7 @@ namespace RPP_FirstLaba_Tractor this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(777, 448); + this.buttonLeft.Location = new System.Drawing.Point(768, 411); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.TabIndex = 3; @@ -170,7 +171,7 @@ namespace RPP_FirstLaba_Tractor this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowDown; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(813, 448); + this.buttonDown.Location = new System.Drawing.Point(804, 411); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.TabIndex = 4; @@ -182,7 +183,7 @@ namespace RPP_FirstLaba_Tractor this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowRight; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(849, 448); + this.buttonRight.Location = new System.Drawing.Point(840, 411); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.TabIndex = 5; @@ -192,7 +193,7 @@ namespace RPP_FirstLaba_Tractor // buttonCreateBulldoserTractor // this.buttonCreateBulldoserTractor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreateBulldoserTractor.Location = new System.Drawing.Point(264, 440); + this.buttonCreateBulldoserTractor.Location = new System.Drawing.Point(264, 403); this.buttonCreateBulldoserTractor.Name = "buttonCreateBulldoserTractor"; this.buttonCreateBulldoserTractor.Size = new System.Drawing.Size(199, 29); this.buttonCreateBulldoserTractor.TabIndex = 6; @@ -203,11 +204,11 @@ namespace RPP_FirstLaba_Tractor // buttonStep // this.buttonStep.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonStep.Location = new System.Drawing.Point(785, 46); + this.buttonStep.Location = new System.Drawing.Point(776, 46); this.buttonStep.Name = "buttonStep"; this.buttonStep.Size = new System.Drawing.Size(94, 29); this.buttonStep.TabIndex = 7; - this.buttonStep.Text = "button2"; + this.buttonStep.Text = ""; this.buttonStep.UseVisualStyleBackColor = true; this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click); // @@ -219,14 +220,14 @@ namespace RPP_FirstLaba_Tractor this.comboBoxStrategy.Items.AddRange(new object[] { " ", " "}); - this.comboBoxStrategy.Location = new System.Drawing.Point(728, 12); + this.comboBoxStrategy.Location = new System.Drawing.Point(719, 12); this.comboBoxStrategy.Name = "comboBoxStrategy"; this.comboBoxStrategy.Size = new System.Drawing.Size(151, 28); this.comboBoxStrategy.TabIndex = 8; // // FormTractor // - this.ClientSize = new System.Drawing.Size(891, 490); + this.ClientSize = new System.Drawing.Size(882, 453); this.Controls.Add(this.comboBoxStrategy); this.Controls.Add(this.buttonStep); this.Controls.Add(this.buttonCreateBulldoserTractor); @@ -246,15 +247,15 @@ namespace RPP_FirstLaba_Tractor private void buttonCreateBulldoserTractor_Click(object sender, EventArgs e) { Random random = new(); - _drawningTractor = new DrawningBuldoserTractor(random.Next(100, 300), + _drawningTractor = new DrawningBulldoser(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)), Convert.ToBoolean(random.Next(0, 2)), - buttonCreateBulldoserTractor.Width, buttonCreateBulldoserTractor.Height); + Convert.ToBoolean(random.Next(0, 2)), + pictureBoxTractor.Width, pictureBoxTractor.Height); _drawningTractor.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); @@ -281,7 +282,7 @@ namespace RPP_FirstLaba_Tractor return; } _abstractStrategy.SetData(new - DrawingObjectTractor(_drawningTractor), pictureBoxTractor.Width, + DrawningObjectTractor(_drawningTractor), pictureBoxTractor.Width, pictureBoxTractor.Height); comboBoxStrategy.Enabled = false; } diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs index 8c19d9c..7280b11 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs @@ -3,13 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -//using RPP_FirstLaba_Tractor.Drawnings; - namespace RPP_FirstLaba_Tractor.MovementStrategy -{/// - /// Интерфейс для работы с перемещаемым объектом - /// +{ + /// + /// Интерфейс для работы с перемещаемым объектом + /// public interface IMoveableObject { /// diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs index c54ee1e..e199e27 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs @@ -6,7 +6,10 @@ using System.Threading.Tasks; namespace RPP_FirstLaba_Tractor.MovementStrategy { - internal class MoveToBorder: AbstractStrategy + /// + /// Стратегия перемещения объекта в центр экрана + /// + public class MoveToBorder : AbstractStrategy { protected override bool IsTargetDestinaion() { @@ -15,10 +18,10 @@ namespace RPP_FirstLaba_Tractor.MovementStrategy { return false; } - return objParams.RightBorder + GetStep() >= FieldWidth && - objParams.DownBorder + GetStep() >= FieldHeight; + return objParams.RightBorder <= FieldWidth + && objParams.RightBorder + GetStep() >= FieldWidth + && objParams.DownBorder + GetStep() >= FieldHeight; } - protected override void MoveToTarget() { var objParams = GetObjectParameters; @@ -26,15 +29,21 @@ namespace RPP_FirstLaba_Tractor.MovementStrategy { return; } - var diffX = FieldWidth - objParams.RightBorder; - if (diffX > GetStep()) + var diffX = objParams.RightBorder - (FieldWidth - 1); + if (Math.Abs(diffX) > GetStep()) { - MoveRight(); + if (diffX < 0) + { + MoveRight(); + } } - var diffY = FieldHeight - objParams.DownBorder; - if (diffY > GetStep()) + var diffY = objParams.DownBorder - (FieldHeight - 1); + if (Math.Abs(diffY) > GetStep()) { - MoveDown(); + if (diffY < 0) + { + MoveDown(); + } } } } diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs index caa4ba2..1e35672 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs @@ -6,7 +6,10 @@ using System.Threading.Tasks; namespace RPP_FirstLaba_Tractor.MovementStrategy { - internal class MoveToCenter: AbstractStrategy + /// + /// Стратегия перемещения объекта в центр экрана + /// + public class MoveToCenter : AbstractStrategy { protected override bool IsTargetDestinaion() { @@ -54,4 +57,3 @@ namespace RPP_FirstLaba_Tractor.MovementStrategy } } } - diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs index 66ea7f7..0ccabc4 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor +namespace RPP_FirstLaba_Tractor.MovementStrategy { /// /// Параметры-координаты объекта @@ -54,4 +54,5 @@ namespace RPP_FirstLaba_Tractor _height = height; } } + } diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs index 69d15ec..9303eda 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs @@ -4,14 +4,15 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor +namespace RPP_FirstLaba_Tractor.MovementStrategy { /// /// Статус выполнения операции перемещения /// public enum Status { - NotInit, InProgress, + NotInit, + InProgress, Finish } diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs deleted file mode 100644 index f7fab51..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Tractor.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RPP_FirstLaba_Tractor.Entities; - -/// -/// Класс-сущность "Автомобиль" -/// -public class EntityTractor -{ - /// - /// Скорость - /// - public int Speed { get; private set; } - /// - /// Вес - /// - public double Weight { get; private set; } - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } - /// - /// Шаг перемещения автомобиля - /// - public double Step => (double)Speed * 100 / Weight; - /// - /// Конструктор с параметрами - /// - /// Скорость - /// Вес автомобиля - /// Основной цвет - public EntityTractor(int speed, double weight, Color bodyColor) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; - } -} - -- 2.25.1 From 679f01efecae25a2a120a6588120c2f028ace446 Mon Sep 17 00:00:00 2001 From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com> Date: Fri, 27 Oct 2023 08:58:51 +0400 Subject: [PATCH 5/6] =?UTF-8?q?=D0=97=D0=B0=D0=BA=D0=BE=D0=BD=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln | 2 +- .../RPP_FirstLaba_Tractor/AbstractStrategy.cs | 4 ++-- .../RPP_FirstLaba_Tractor/DirectionType.cs | 2 +- .../RPP_FirstLaba_Tractor/DrawningBulldoser.cs | 5 +++-- .../DrawningObjectTractor.cs | 9 +++++++-- .../RPP_FirstLaba_Tractor/DrawningTractor.cs | 6 +++--- .../RPP_FirstLaba_Tractor/EntityBulldoser.cs | 2 +- .../RPP_FirstLaba_Tractor/EntityTractor.cs | 2 +- .../RPP_FirstLaba_Tractor/FormTractor.cs | 15 ++++++++------- .../RPP_FirstLaba_Tractor/IMoveableObject.cs | 4 +++- .../RPP_FirstLaba_Tractor/MoveToBorder.cs | 2 +- .../RPP_FirstLaba_Tractor/MoveToCenter.cs | 2 +- .../RPP_FirstLaba_Tractor/ObjectParameters.cs | 2 +- .../RPP_FirstLaba_Tractor/Program.cs | 2 +- ...tLaba_Tractor.csproj => ProjectTractor.csproj} | 0 .../Properties/Resources.Designer.cs | 4 ++-- .../RPP_FirstLaba_Tractor/Status.cs | 2 +- 17 files changed, 37 insertions(+), 28 deletions(-) rename RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/{RPP_FirstLaba_Tractor.csproj => ProjectTractor.csproj} (100%) diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln index f5b346e..0be4f9c 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.2.32602.215 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RPP_FirstLaba_Tractor", "RPP_FirstLaba_Tractor\RPP_FirstLaba_Tractor.csproj", "{EF413F48-FFBF-4510-BA11-FAEBE7C0142A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectTractor", "RPP_FirstLaba_Tractor\ProjectTractor.csproj", "{EF413F48-FFBF-4510-BA11-FAEBE7C0142A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs index ac1f0f9..f3605ef 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/AbstractStrategy.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using RPP_FirstLaba_Tractor.DrawningObjects; +using ProjectTractor.DrawningObjects; -namespace RPP_FirstLaba_Tractor.MovementStrategy +namespace ProjectTractor.MovementStrategy { /// /// Класс-стратегия перемещения объекта diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DirectionType.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DirectionType.cs index c561ded..5489883 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DirectionType.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DirectionType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor +namespace ProjectTractor { public enum DirectionType { diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs index f179a96..ca3eb8a 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using RPP_FirstLaba_Tractor.Entities; +using ProjectTractor.Entities; -namespace RPP_FirstLaba_Tractor.DrawningObjects +namespace ProjectTractor.DrawningObjects { /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности @@ -44,6 +44,7 @@ namespace RPP_FirstLaba_Tractor.DrawningObjects SolidBrush(bulldoser.AdditionalColor); base.DrawTransport(g); + // орнамент на колесах if (bulldoser.WheelsOrnament) { g.FillEllipse(additionalBrush, _startPosX + 2, _startPosY + 47, 11, 11); diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningObjectTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningObjectTractor.cs index 969c4ee..48469c8 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningObjectTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningObjectTractor.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using RPP_FirstLaba_Tractor.DrawningObjects; +using ProjectTractor.DrawningObjects; -namespace RPP_FirstLaba_Tractor.MovementStrategy +namespace ProjectTractor.MovementStrategy { /// /// Реализация интерфейса IDrawningObject для работы с объектом DrawningTractor(паттерн Adapter) @@ -35,6 +35,11 @@ namespace RPP_FirstLaba_Tractor.MovementStrategy _drawningTractor?.CanMove(direction) ?? false; public void MoveObject(DirectionType direction) => _drawningTractor?.MoveTransport(direction); + + public void getData() + { + + } } } diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs index a888485..c5af8d8 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using RPP_FirstLaba_Tractor.Entities; +using ProjectTractor.Entities; -namespace RPP_FirstLaba_Tractor.DrawningObjects { +namespace ProjectTractor.DrawningObjects { /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности @@ -115,7 +115,7 @@ namespace RPP_FirstLaba_Tractor.DrawningObjects { DirectionType.Up => _startPosY - EntityTractor.Step > 0, // вправо DirectionType.Right => _startPosX + EntityTractor.Step + _tractorWidth < _pictureWidth, - //вниз + // вниз DirectionType.Down => _startPosY + EntityTractor.Step + _tractorHeight < _pictureHeight, _ => false, }; diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs index 29be4a0..b71fcd3 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor.Entities +namespace ProjectTractor.Entities { /// /// Класс-сущность "Спортивный автомобиль" diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs index 8a7e41a..17d046f 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor.Entities +namespace ProjectTractor.Entities { /// /// Класс-сущность "Автомобиль" diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs index 551ed9f..4dcb86d 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs @@ -1,9 +1,10 @@ -using RPP_FirstLaba_Tractor.MovementStrategy; -using RPP_FirstLaba_Tractor.DrawningObjects; +using ProjectTractor.MovementStrategy; +using ProjectTractor.DrawningObjects; -namespace RPP_FirstLaba_Tractor +namespace ProjectTractor { + /// /// " " /// @@ -145,7 +146,7 @@ namespace RPP_FirstLaba_Tractor // buttonTop // this.buttonTop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonTop.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowUp; + this.buttonTop.BackgroundImage = global::ProjectTractor.Properties.Resources.arrowUp; this.buttonTop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonTop.Location = new System.Drawing.Point(804, 375); this.buttonTop.Name = "buttonTop"; @@ -157,7 +158,7 @@ namespace RPP_FirstLaba_Tractor // buttonLeft // this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonLeft.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowLeft; + this.buttonLeft.BackgroundImage = global::ProjectTractor.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonLeft.Location = new System.Drawing.Point(768, 411); this.buttonLeft.Name = "buttonLeft"; @@ -169,7 +170,7 @@ namespace RPP_FirstLaba_Tractor // buttonDown // this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowDown; + this.buttonDown.BackgroundImage = global::ProjectTractor.Properties.Resources.arrowDown; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonDown.Location = new System.Drawing.Point(804, 411); this.buttonDown.Name = "buttonDown"; @@ -181,7 +182,7 @@ namespace RPP_FirstLaba_Tractor // buttonRight // this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRight.BackgroundImage = global::RPP_FirstLaba_Tractor.Properties.Resources.arrowRight; + this.buttonRight.BackgroundImage = global::ProjectTractor.Properties.Resources.arrowRight; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRight.Location = new System.Drawing.Point(840, 411); this.buttonRight.Name = "buttonRight"; diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs index 7280b11..0c9d616 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/IMoveableObject.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor.MovementStrategy +namespace ProjectTractor.MovementStrategy { /// /// Интерфейс для работы с перемещаемым объектом @@ -30,6 +30,8 @@ namespace RPP_FirstLaba_Tractor.MovementStrategy /// /// Направление void MoveObject(DirectionType direction); + + } } diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs index e199e27..362ec52 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToBorder.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor.MovementStrategy +namespace ProjectTractor.MovementStrategy { /// /// Стратегия перемещения объекта в центр экрана diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs index 1e35672..48d09d4 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/MoveToCenter.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor.MovementStrategy +namespace ProjectTractor.MovementStrategy { /// /// Стратегия перемещения объекта в центр экрана diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs index 0ccabc4..e75f70f 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ObjectParameters.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor.MovementStrategy +namespace ProjectTractor.MovementStrategy { /// /// Параметры-координаты объекта diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs index 7556447..61dbba1 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs @@ -1,4 +1,4 @@ -namespace RPP_FirstLaba_Tractor +namespace ProjectTractor { internal static class Program { diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.csproj b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ProjectTractor.csproj similarity index 100% rename from RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.csproj rename to RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/ProjectTractor.csproj diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.Designer.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.Designer.cs index 86bf022..112e027 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.Designer.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace RPP_FirstLaba_Tractor.Properties { +namespace ProjectTractor.Properties { using System; @@ -39,7 +39,7 @@ namespace RPP_FirstLaba_Tractor.Properties { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RPP_FirstLaba_Tractor.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectTractor.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs index 9303eda..6cb1b3d 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Status.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace RPP_FirstLaba_Tractor.MovementStrategy +namespace ProjectTractor.MovementStrategy { /// /// Статус выполнения операции перемещения -- 2.25.1 From 07e6b5fba6a6aa2da241f92e13b88327dadd038a Mon Sep 17 00:00:00 2001 From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com> Date: Sat, 28 Oct 2023 22:37:28 +0400 Subject: [PATCH 6/6] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._FirstLaba_Tractor.sln => RPP_Firsov_Kirill_Tractor_basis.sln} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename RPP_FirstLaba_Tractor/{RPP_FirstLaba_Tractor.sln => RPP_Firsov_Kirill_Tractor_basis.sln} (100%) diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln b/RPP_FirstLaba_Tractor/RPP_Firsov_Kirill_Tractor_basis.sln similarity index 100% rename from RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor.sln rename to RPP_FirstLaba_Tractor/RPP_Firsov_Kirill_Tractor_basis.sln -- 2.25.1