diff --git a/ProjectBoat_bae/ProjectBoat_bae/DrawningObjects/DrawningBoat.cs b/ProjectBoat_bae/ProjectBoat_bae/DrawningObjects/DrawningBoat.cs
index e08e97f..aca6b1c 100644
--- a/ProjectBoat_bae/ProjectBoat_bae/DrawningObjects/DrawningBoat.cs
+++ b/ProjectBoat_bae/ProjectBoat_bae/DrawningObjects/DrawningBoat.cs
@@ -8,10 +8,15 @@ using System.Text;
using ProjectBoat_bae;
using ProjectBoat_bae.Entities;
+using ProjectBoat_bae.MovementStrategy;
+
namespace ProjectBoat_bae.DrawningObjects
{
public class Drawningboat
{
+ // Получение объекта IMoveableObject из объекта DrawningCar
+ public IMoveableObject GetMoveableObject => new
+ DrawningObjectBoat(this);
// Класс-сущность
public EntityBoat? EntityBoat { get; protected set; }
diff --git a/ProjectBoat_bae/ProjectBoat_bae/Form1.Designer.cs b/ProjectBoat_bae/ProjectBoat_bae/Form1.Designer.cs
index b84b208..1e4a774 100644
--- a/ProjectBoat_bae/ProjectBoat_bae/Form1.Designer.cs
+++ b/ProjectBoat_bae/ProjectBoat_bae/Form1.Designer.cs
@@ -38,6 +38,7 @@
buttonClickMotorBoat = new Button();
buttonStep = new Button();
comboBoxStrategy = new ComboBox();
+ buttonSelectBoat_Click = new Button();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
@@ -144,11 +145,22 @@
comboBoxStrategy.Size = new Size(182, 33);
comboBoxStrategy.TabIndex = 9;
//
+ // buttonSelectBoat_Click
+ //
+ buttonSelectBoat_Click.Location = new Point(517, 598);
+ buttonSelectBoat_Click.Name = "buttonSelectBoat_Click";
+ buttonSelectBoat_Click.Size = new Size(233, 34);
+ buttonSelectBoat_Click.TabIndex = 10;
+ buttonSelectBoat_Click.Text = "Выбранная лодка";
+ buttonSelectBoat_Click.UseVisualStyleBackColor = true;
+ buttonSelectBoat_Click.Click += this.buttonSelectBoat_Click_Click;
+ //
// FormBoat
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1178, 644);
+ Controls.Add(buttonSelectBoat_Click);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonStep);
Controls.Add(buttonClickMotorBoat);
@@ -176,5 +188,7 @@
private Button buttonClickMotorBoat;
private Button buttonStep;
private ComboBox comboBoxStrategy;
+ private Button button1;
+ private Button buttonSelectBoat_Click;
}
}
\ No newline at end of file
diff --git a/ProjectBoat_bae/ProjectBoat_bae/Form1.cs b/ProjectBoat_bae/ProjectBoat_bae/Form1.cs
index 63deff8..67551b1 100644
--- a/ProjectBoat_bae/ProjectBoat_bae/Form1.cs
+++ b/ProjectBoat_bae/ProjectBoat_bae/Form1.cs
@@ -8,8 +8,6 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
-using ProjectBoat_bae;
-using ProjectBoat_bae.Properties;
using ProjectBoat_bae.Entities;
using ProjectBoat_bae.MovementStrategy;
using ProjectBoat_bae.DrawningObjects;
@@ -22,10 +20,14 @@ namespace ProjectBoat_bae
private Drawningboat? _drawingBoat;
private AbstractStrategy? _abstractStrategy;
+ ///
+ public Drawningboat? SelectedBoat { get; private set; }
public FormBoat()
{
InitializeComponent();
+ _abstractStrategy = null;
+ SelectedBoat = null;
}
//
@@ -69,19 +71,39 @@ namespace ProjectBoat_bae
}
private void buttonClickMotorBoat_Click(object sender, EventArgs e)
{
- Random random = new Random();
- _drawingBoat = new DrawningMotorBoat(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)),
+ Random random = new();
+ Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+
+ Color dopColor = Color.FromArgb(random.Next(0, 256),
+ random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dialogAddColor = new();
+ if (dialogAddColor.ShowDialog() == DialogResult.OK)
+ {
+ dopColor = dialogAddColor.Color;
+ }
+
+ _drawingBoat = new DrawningMotorBoat(random.Next(100, 300),
+ random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)),
- Convert.ToBoolean(random.Next(0, 2)), pictureBox1.Width, pictureBox1.Height);
+ pictureBox1.Width, pictureBox1.Height);
_drawingBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonClick_Click(object sender, EventArgs e)
{
Random random = new();
- _drawingBoat = new Drawningboat(random.Next(100, 300), random.Next(1000, 3000),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- pictureBox1.Width, pictureBox1.Height);
+ Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+ _drawingBoat = new Drawningboat(random.Next(100, 300), random.Next(1000, 3000), color, pictureBox1.Width, pictureBox1.Height);
_drawingBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
@@ -120,5 +142,11 @@ namespace ProjectBoat_bae
_abstractStrategy = null;
}
}
+
+ private void buttonSelectBoat_Click_Click(object sender, EventArgs e)
+ {
+ SelectedBoat = _drawingBoat;
+ DialogResult = DialogResult.OK;
+ }
}
}
\ No newline at end of file
diff --git a/ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.Designer.cs b/ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.Designer.cs
new file mode 100644
index 0000000..0239366
--- /dev/null
+++ b/ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.Designer.cs
@@ -0,0 +1,124 @@
+namespace ProjectBoat_bae
+{
+ partial class FormBoatCollection
+ {
+ ///
+ /// 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()
+ {
+ pictureBoxCollection = new PictureBox();
+ buttonAddBoat_Click = new Button();
+ buttonRemoveBoat_Click = new Button();
+ buttonRefreshCollection_Click = new Button();
+ textBox1 = new TextBox();
+ maskedTextBoxNumber = new MaskedTextBox();
+ ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
+ SuspendLayout();
+ //
+ // pictureBoxCollection
+ //
+ pictureBoxCollection.Location = new Point(0, 0);
+ pictureBoxCollection.Name = "pictureBoxCollection";
+ pictureBoxCollection.Size = new Size(1176, 647);
+ pictureBoxCollection.SizeMode = PictureBoxSizeMode.AutoSize;
+ pictureBoxCollection.TabIndex = 0;
+ pictureBoxCollection.TabStop = false;
+ //
+ // buttonAddBoat_Click
+ //
+ buttonAddBoat_Click.Location = new Point(955, 73);
+ buttonAddBoat_Click.Name = "buttonAddBoat_Click";
+ buttonAddBoat_Click.Size = new Size(201, 47);
+ buttonAddBoat_Click.TabIndex = 1;
+ buttonAddBoat_Click.Text = "Добавить лодку";
+ buttonAddBoat_Click.UseVisualStyleBackColor = true;
+ buttonAddBoat_Click.Click += buttonAddBoat_Click_Click;
+ //
+ // buttonRemoveBoat_Click
+ //
+ buttonRemoveBoat_Click.Location = new Point(955, 345);
+ buttonRemoveBoat_Click.Name = "buttonRemoveBoat_Click";
+ buttonRemoveBoat_Click.Size = new Size(201, 46);
+ buttonRemoveBoat_Click.TabIndex = 2;
+ buttonRemoveBoat_Click.Text = "Удалить лодку";
+ buttonRemoveBoat_Click.UseVisualStyleBackColor = true;
+ buttonRemoveBoat_Click.Click += buttonRemoveBoat_Click_Click;
+ //
+ // buttonRefreshCollection_Click
+ //
+ buttonRefreshCollection_Click.Location = new Point(955, 421);
+ buttonRefreshCollection_Click.Name = "buttonRefreshCollection_Click";
+ buttonRefreshCollection_Click.Size = new Size(201, 50);
+ buttonRefreshCollection_Click.TabIndex = 3;
+ buttonRefreshCollection_Click.Text = "Обновить коллекцию";
+ buttonRefreshCollection_Click.UseVisualStyleBackColor = true;
+ buttonRefreshCollection_Click.Click += buttonRefreshCollection_Click_Click;
+ //
+ // textBox1
+ //
+ textBox1.BackColor = SystemColors.MenuBar;
+ textBox1.Location = new Point(955, 12);
+ textBox1.Name = "textBox1";
+ textBox1.Size = new Size(150, 31);
+ textBox1.TabIndex = 4;
+ textBox1.Text = "Инструменты";
+ textBox1.TextAlign = HorizontalAlignment.Center;
+ //
+ // maskedTextBoxNumber
+ //
+ maskedTextBoxNumber.Location = new Point(979, 293);
+ maskedTextBoxNumber.Name = "maskedTextBoxNumber";
+ maskedTextBoxNumber.Size = new Size(150, 31);
+ maskedTextBoxNumber.TabIndex = 5;
+ maskedTextBoxNumber.Text = "_";
+ //
+ // FormBoatCollection
+ //
+ AutoScaleDimensions = new SizeF(10F, 25F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1178, 644);
+ Controls.Add(maskedTextBoxNumber);
+ Controls.Add(textBox1);
+ Controls.Add(buttonRefreshCollection_Click);
+ Controls.Add(buttonRemoveBoat_Click);
+ Controls.Add(buttonAddBoat_Click);
+ Controls.Add(pictureBoxCollection);
+ Name = "FormBoatCollection";
+ Text = "FormBoatCollection";
+ ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private PictureBox pictureBoxCollection;
+ private Button buttonAddBoat_Click;
+ private Button buttonRemoveBoat_Click;
+ private Button buttonRefreshCollection_Click;
+ private TextBox textBox1;
+ private MaskedTextBox maskedTextBoxNumber;
+ }
+}
\ No newline at end of file
diff --git a/ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.cs b/ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.cs
new file mode 100644
index 0000000..9c5ba2a
--- /dev/null
+++ b/ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Numerics;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+using ProjectBoat_bae.DrawningObjects;
+using ProjectBoat_bae.Generics;
+using ProjectBoat_bae.MovementStrategy;
+
+namespace ProjectBoat_bae
+{
+ public partial class FormBoatCollection : Form
+ {
+
+ private readonly BoatsGenericCollection _boats;
+
+ public FormBoatCollection()
+ {
+ InitializeComponent();
+ _boats = new BoatsGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height);
+ }
+
+ // Добавление объекта в набор
+ private void buttonAddBoat_Click_Click(object sender, EventArgs e)
+ {
+ FormBoat form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (_boats + form.SelectedBoat != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = _boats.ShowBoats();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+
+ // Удаление объекта из набора
+ private void buttonRemoveBoat_Click_Click(object sender, EventArgs e)
+ {
+ if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ //int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
+ //if (_boats - pos != null)
+ //{
+ // MessageBox.Show("Объект удален");
+ // pictureBoxCollection.Image = _boats.ShowBoats();
+ //}
+ //else
+ //{
+ // MessageBox.Show("Не удалось удалить объект");
+ //}
+ int pos = -1;
+ try
+ {
+ pos = Convert.ToInt32(maskedTextBoxNumber.Text);
+ }
+ catch (Exception ex) { }
+ if (_boats - pos)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBoxCollection.Image = _boats.ShowBoats();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+
+
+ }
+
+ private void buttonRefreshCollection_Click_Click(object sender, EventArgs e)
+ {
+ pictureBoxCollection.Image = _boats.ShowBoats();
+ }
+ }
+}
diff --git a/laba3(base)/laba3(base)/Form1.resx b/ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.resx
similarity index 93%
rename from laba3(base)/laba3(base)/Form1.resx
rename to ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.resx
index 1af7de1..af32865 100644
--- a/laba3(base)/laba3(base)/Form1.resx
+++ b/ProjectBoat_bae/ProjectBoat_bae/FormBoatCollection.resx
@@ -1,17 +1,17 @@
-
diff --git a/ProjectBoat_bae/ProjectBoat_bae/Generics/BoatsGenericCollection.cs b/ProjectBoat_bae/ProjectBoat_bae/Generics/BoatsGenericCollection.cs
new file mode 100644
index 0000000..ad75009
--- /dev/null
+++ b/ProjectBoat_bae/ProjectBoat_bae/Generics/BoatsGenericCollection.cs
@@ -0,0 +1,114 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ProjectBoat_bae.MovementStrategy;
+using ProjectBoat_bae.DrawningObjects;
+
+namespace ProjectBoat_bae.Generics
+{
+ internal class BoatsGenericCollection
+ where T : Drawningboat
+ where U : IMoveableObject
+ {
+ // Ширина окна прорисовки
+ private readonly int _pictureWidth;
+
+ // Высота окна прорисовки
+ private readonly int _pictureHeight;
+ ///
+ /// Размер занимаемого объектом места (ширина)
+ ///
+ private readonly int _placeSizeWidth = 160;
+
+ // Размер занимаемого объектом места (высота)
+ private readonly int _placeSizeHeight = 160;
+
+ // Набор объектов
+ private readonly SetGeneric _collection;
+
+ // Конструктор
+ public BoatsGenericCollection(int picWidth, int picHeight)
+ {
+ int width = picWidth / _placeSizeWidth;
+ int height = picHeight / _placeSizeHeight;
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _collection = new SetGeneric(width * height);
+ }
+
+ // Перегрузка оператора сложения
+ public static int operator +(BoatsGenericCollection collect, T?
+ obj)
+ {
+ if (obj == null)
+ {
+ return -1;
+ }
+ return collect._collection.Insert(obj);
+ }
+
+ // Перегрузка оператора вычитания
+ public static bool operator -(BoatsGenericCollection collect, int
+ pos)
+ {
+ T? obj = collect._collection.Get(pos);
+ if (obj != null)
+ {
+ collect._collection.Remove(pos);
+ }
+ return false;
+ }
+
+ // Получение объекта IMoveableObject
+ public U? GetU(int pos)
+ {
+ return (U?)_collection.Get(pos)?.GetMoveableObject;
+ }
+
+ // Вывод всего набора объектов
+ public Bitmap ShowBoats()
+ {
+ Bitmap bmp = new(_pictureWidth, _pictureHeight);
+ Graphics gr = Graphics.FromImage(bmp);
+ DrawBackground(gr);
+ DrawObjects(gr);
+ return bmp;
+ }
+
+ // Метод отрисовки фона
+ private void DrawBackground(Graphics g)
+ {
+ Pen pen = new(Color.Black, 3);
+ for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
+ {
+ for (int j = 0; j < _pictureHeight / _placeSizeHeight +
+ 1; ++j)
+ {//линия рамзетки места
+ g.DrawLine(pen, i * _placeSizeWidth, j *
+ _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
+ _placeSizeHeight);
+ }
+ g.DrawLine(pen, i * _placeSizeWidth, 0, i *
+ _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
+ }
+ }
+
+ // Метод прорисовки объектов
+ private void DrawObjects(Graphics g)
+ {
+ for (int i = 0; i < _collection.Count; i++)
+ {
+ Drawningboat boat = _collection.Get(i);
+
+ if (boat != null)
+ {
+ int width = _pictureWidth / _placeSizeWidth;
+ boat.SetPosition(i % width * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
+ boat.DrawTransport(g);
+ }
+ }
+ }
+ }
+}
diff --git a/ProjectBoat_bae/ProjectBoat_bae/Generics/SetGeneric.cs b/ProjectBoat_bae/ProjectBoat_bae/Generics/SetGeneric.cs
new file mode 100644
index 0000000..31de8c8
--- /dev/null
+++ b/ProjectBoat_bae/ProjectBoat_bae/Generics/SetGeneric.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBoat_bae.Generics
+{
+ internal class SetGeneric where T : class
+ {
+ private readonly T?[] _places;
+
+ public int Count => _places.Length;
+
+ public SetGeneric(int count)
+ {
+ _places = new T?[count];
+ }
+
+ public int Insert(T boat)
+ {
+ if (_places[Count - 1] != null)
+ return -1;
+ return Insert(boat, 0);
+ }
+
+ public int Insert(T boat, int position)
+ {
+ if (position < 0 || position >= Count)
+ return -1;
+ if (_places[position] != null)
+ {
+ int indexEnd = position + 1;
+ while (_places[indexEnd] != null)
+ {
+ indexEnd++;
+ }
+ for (int i = indexEnd + 1; i > position; i--)
+ {
+ _places[i] = _places[i - 1];
+ }
+
+ }
+ _places[position] = boat;
+ return position;
+ }
+
+ public bool Remove(int position)
+ {
+ if (position < 0 || position >= _places.Count())
+ return false;
+
+ _places[position] = null;
+
+ return true;
+ }
+
+ public T? Get(int position)
+ {
+ if (position < 0 || position >= _places.Count())
+ return null;
+ return _places[position];
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/ProjectBoat_bae/ProjectBoat_bae/Program.cs b/ProjectBoat_bae/ProjectBoat_bae/Program.cs
index b9eb946..ba97b20 100644
--- a/ProjectBoat_bae/ProjectBoat_bae/Program.cs
+++ b/ProjectBoat_bae/ProjectBoat_bae/Program.cs
@@ -11,7 +11,7 @@ namespace ProjectBoat_bae
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormBoat());
+ Application.Run(new FormBoatCollection());
}
}
}
\ No newline at end of file
diff --git a/laba3(base)/laba3(base).sln b/laba3(base)/laba3(base).sln
deleted file mode 100644
index a590d58..0000000
--- a/laba3(base)/laba3(base).sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.7.34031.279
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "laba3(base)", "laba3(base)\laba3(base).csproj", "{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {DBC78A3D-9D37-411B-8DAD-A904CC5BF8E0}
- EndGlobalSection
-EndGlobal
diff --git a/laba3(base)/laba3(base)/Form1.Designer.cs b/laba3(base)/laba3(base)/Form1.Designer.cs
deleted file mode 100644
index 752521e..0000000
--- a/laba3(base)/laba3(base)/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace laba3_base_
-{
- 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/laba3(base)/laba3(base)/Form1.cs b/laba3(base)/laba3(base)/Form1.cs
deleted file mode 100644
index db2025b..0000000
--- a/laba3(base)/laba3(base)/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace laba3_base_
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/laba3(base)/laba3(base)/Generics/CarsGenericCollection.cs b/laba3(base)/laba3(base)/Generics/CarsGenericCollection.cs
deleted file mode 100644
index 2ff2ca8..0000000
--- a/laba3(base)/laba3(base)/Generics/CarsGenericCollection.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace laba3_base_.Generics
-{
- internal class CarsGenericCollection
- where T : DrawningPlane
- where U : IMoveableObject
- {
- ///
- /// Ширина окна прорисовки
- ///
- private readonly int _pictureWidth;
- ///
- /// Высота окна прорисовки
- ///
- private readonly int _pictureHeight;
- ///
- /// Размер занимаемого объектом места (ширина)
- ///
- private readonly int _placeSizeWidth = 175;
- ///
- /// Размер занимаемого объектом места (высота)
- ///
- private readonly int _placeSizeHeight = 80;
- ///
- /// Набор объектов
- ///
- private readonly SetGeneric _collection;
- ///
- /// Конструктор
- ///
- ///
- ///
- public PlanesGenericCollection(int picWidth, int picHeight)
- {
- int width = picWidth / _placeSizeWidth;
- int height = picHeight / _placeSizeHeight;
- _pictureWidth = picWidth;
- _pictureHeight = picHeight;
- _collection = new SetGeneric(width * height);
- }
- ///
- /// Перегрузка оператора сложения
- ///
- ///
- ///
- ///
- public static bool operator +(PlanesGenericCollection collect, T?
- obj)
- {
- if (obj == null)
- {
- return false;
- }
- return collect?._collection.Insert(obj) ?? false;
- }
- ///
- /// Перегрузка оператора вычитания
- ///
- ///
- ///
- ///
- public static T? operator -(PlanesGenericCollection collect, int
- pos)
- {
- T? obj = collect._collection.Get(pos);
- if (obj != null)
- {
- collect._collection.Remove(pos);
- }
- return obj;
- }
- ///
- /// Получение объекта IMoveableObject
- ///
- ///
- ///
- public U? GetU(int pos)
- {
- return (U?)_collection.Get(pos)?.GetMoveableObject;
- }
- ///
- /// Вывод всего набора объектов
- ///
- ///
- public Bitmap ShowCars()
- {
- Bitmap bmp = new(_pictureWidth, _pictureHeight);
- Graphics gr = Graphics.FromImage(bmp);
- DrawBackground(gr);
- DrawObjects(gr);
- return bmp;
- }
- ///
- /// Метод отрисовки фона
- ///
- ///
- private void DrawBackground(Graphics g)
- {
- Pen pen = new(Color.Black, 3);
- for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
- {
- for (int j = 0; j < _pictureHeight / _placeSizeHeight +
- 1; ++j)
- {//линия рамзетки места
- g.DrawLine(pen, i * _placeSizeWidth, j *
- _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
- _placeSizeHeight);
- }
- g.DrawLine(pen, i * _placeSizeWidth, 0, i *
- _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
- }
- }
- ///
- /// Метод прорисовки объектов
- ///
- ///
- private void DrawObjects(Graphics g)
- {
- for (int i = 0; i < _collection.Count; i++)
- {
- // TODO получение объекта
- // TODO установка позиции
- // TODO прорисовка объекта
- }
- }
- }
-}
diff --git a/laba3(base)/laba3(base)/Generics/SetGeneric.cs b/laba3(base)/laba3(base)/Generics/SetGeneric.cs
deleted file mode 100644
index 14c737e..0000000
--- a/laba3(base)/laba3(base)/Generics/SetGeneric.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Numerics;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace laba3_base_.Generics
-{
- internal class SetGeneric
- where T : class
- {
- // Массив объектов, которые храним
- private readonly T?[] _places;
-
- // Количество объектов в массиве
- public int Count => _places.Length;
-
- // Конструктор
- public SetGeneric(int count)
- {
- _places = new T?[count];
- }
-
- // Добавление объекта в набор
- public bool Insert(T car)
- {
- try
- {
- for (int i = _places.Length - 1; i > 0; i--)
- {
- _places[i] = _places[i - 1];
- }
- _places[0] = car;
- return true;
- }
- catch
- {
- return false;
- }
- }
-
- // Добавление объекта в набор на конкретную позицию
- public bool Insert(T car, int position)
- {
- if (position < 0 || position >= _places.Count() || car == null)
- {
- return false;
- }
- if (_places[position] == null)
- {
- return false;
-
- }
- int positionNull = Array.FindIndex(_places, position, x => x == null);
- if (positionNull == -1)
- return false;
- for (int i = positionNull; i > position; i--)
- {
- _places[i] = _places[i - 1];
- }
- _places[position] = car;
- return true;
- }
-
- // Удаление объекта из набора с конкретной позиции
- public bool Remove(int position)
- {
- if (position < 0 || position >= _places.Count())
- return false;
-
- _places[position] = null;
-
- return true;
- }
- // Получение объекта из набора по позиции
- public T? Get(int position)
- {
- if (position < 0 || position >= _places.Count())
- return null;
- return _places[position];
-
- }
- }
-}
diff --git a/laba3(base)/laba3(base)/Program.cs b/laba3(base)/laba3(base)/Program.cs
deleted file mode 100644
index d293e98..0000000
--- a/laba3(base)/laba3(base)/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace laba3_base_
-{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
- }
- }
-}
\ No newline at end of file
diff --git a/laba3(base)/laba3(base)/laba3(base).csproj b/laba3(base)/laba3(base)/laba3(base).csproj
deleted file mode 100644
index 2bdfff0..0000000
--- a/laba3(base)/laba3(base)/laba3(base).csproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- WinExe
- net6.0-windows
- laba3_base_
- enable
- true
- enable
-
-
-
\ No newline at end of file