From d4637f5853ef41778180518a7457ef0bfb33d820 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 17:24:39 +0400 Subject: [PATCH 01/13] =?UTF-8?q?=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D0=B1=D1=8B=D0=BB=D0=BE=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BE=D0=BA=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B8=D0=BB=D1=8F=D1=86?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs b/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs index c15abbb..db0900e 100644 --- a/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs +++ b/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs @@ -26,7 +26,7 @@ public class EntitySportCar : EntityCar public bool SportLine { get; private set; } /// - /// Инициализация полей объекта-класса спортивного автомобиля + /// Конструктор сущности /// /// Скорость /// Вес автомобиля @@ -35,7 +35,7 @@ public class EntitySportCar : EntityCar /// Признак наличия обвеса /// Признак наличия антикрыла /// Признак наличия гоночной полосы - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) + public EntitySportCar(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) : base(0, 0, Color.Black) { AdditionalColor = additionalColor; BodyKit = bodyKit; From 1358d1f9699d93660842e3acc4c6d8d6353adfd7 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 17:36:56 +0400 Subject: [PATCH 02/13] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionGenericObjects/CarSharingService.cs | 9 +++++++++ ProjectSportCar/ProjectSportCar/FormCarCollection.cs | 1 + 2 files changed, 10 insertions(+) diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/CarSharingService.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/CarSharingService.cs index e73434f..1060292 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/CarSharingService.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/CarSharingService.cs @@ -2,8 +2,17 @@ namespace ProjectSportCar.CollectionGenericObjects; +/// +/// Реализация абстрактной компании - каршеринг +/// public class CarSharingService : AbstractCompany { + /// + /// Конструктор + /// + /// + /// + /// public CarSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) { } diff --git a/ProjectSportCar/ProjectSportCar/FormCarCollection.cs b/ProjectSportCar/ProjectSportCar/FormCarCollection.cs index 6cbc738..9d26a36 100644 --- a/ProjectSportCar/ProjectSportCar/FormCarCollection.cs +++ b/ProjectSportCar/ProjectSportCar/FormCarCollection.cs @@ -69,6 +69,7 @@ public partial class FormCarCollection : Form drawningCar = new DrawningCar(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); break; case nameof(DrawningSportCar): + // TODO вызов диалогового окна для выбора цвета drawningCar = new DrawningSportCar(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)), From 5cfde610e791ef407617d92ab382476476eb766f Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 17:38:42 +0400 Subject: [PATCH 03/13] =?UTF-8?q?=D0=BE=D0=BF=D0=B5=D1=87=D0=B0=D1=82?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectSportCar/ProjectSportCar/FormSportCar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectSportCar/ProjectSportCar/FormSportCar.cs b/ProjectSportCar/ProjectSportCar/FormSportCar.cs index 74f0505..3d3975f 100644 --- a/ProjectSportCar/ProjectSportCar/FormSportCar.cs +++ b/ProjectSportCar/ProjectSportCar/FormSportCar.cs @@ -53,7 +53,7 @@ public partial class FormSportCar : Form } /// - /// Перемешение объекта по форме (нажатие кнопок навигации) + /// Перемещение объекта по форме (нажатие кнопок навигации) /// /// /// From a4cd1c3b18f9bf57d4830672c3c6303ea6b068fa Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 18:47:36 +0400 Subject: [PATCH 04/13] =?UTF-8?q?=D0=B8=D0=BC=D1=8F=20=D0=BF=D0=B0=D0=BD?= =?UTF-8?q?=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSportCar/FormCarConfig.Designer.cs | 18 +++++++++--------- .../ProjectSportCar/FormCarConfig.cs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/FormCarConfig.Designer.cs b/ProjectSportCar/ProjectSportCar/FormCarConfig.Designer.cs index 0cbfa94..5383934 100644 --- a/ProjectSportCar/ProjectSportCar/FormCarConfig.Designer.cs +++ b/ProjectSportCar/ProjectSportCar/FormCarConfig.Designer.cs @@ -33,7 +33,7 @@ panelPurple = new Panel(); panelYellow = new Panel(); panelBlack = new Panel(); - panelGrey = new Panel(); + panelGray = new Panel(); panelBlue = new Panel(); panelWhite = new Panel(); panelGreen = new Panel(); @@ -86,7 +86,7 @@ groupBoxColors.Controls.Add(panelPurple); groupBoxColors.Controls.Add(panelYellow); groupBoxColors.Controls.Add(panelBlack); - groupBoxColors.Controls.Add(panelGrey); + groupBoxColors.Controls.Add(panelGray); groupBoxColors.Controls.Add(panelBlue); groupBoxColors.Controls.Add(panelWhite); groupBoxColors.Controls.Add(panelGreen); @@ -122,13 +122,13 @@ panelBlack.Size = new Size(34, 34); panelBlack.TabIndex = 4; // - // panelGrey + // panelGray // - panelGrey.BackColor = Color.Gray; - panelGrey.Location = new Point(67, 66); - panelGrey.Name = "panelGrey"; - panelGrey.Size = new Size(34, 34); - panelGrey.TabIndex = 5; + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(67, 66); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(34, 34); + panelGray.TabIndex = 5; // // panelBlue // @@ -349,7 +349,7 @@ private Panel panelPurple; private Panel panelYellow; private Panel panelBlack; - private Panel panelGrey; + private Panel panelGray; private Panel panelBlue; private Panel panelWhite; private Panel panelGreen; diff --git a/ProjectSportCar/ProjectSportCar/FormCarConfig.cs b/ProjectSportCar/ProjectSportCar/FormCarConfig.cs index 61b5f9d..2f7855a 100644 --- a/ProjectSportCar/ProjectSportCar/FormCarConfig.cs +++ b/ProjectSportCar/ProjectSportCar/FormCarConfig.cs @@ -27,7 +27,7 @@ public partial class FormCarConfig : Form panelBlue.MouseDown += Panel_MouseDown; panelYellow.MouseDown += Panel_MouseDown; panelWhite.MouseDown += Panel_MouseDown; - panelGrey.MouseDown += Panel_MouseDown; + panelGray.MouseDown += Panel_MouseDown; panelBlack.MouseDown += Panel_MouseDown; panelPurple.MouseDown += Panel_MouseDown; From 13a4dd128f5de06d3d926b31ba2644cc2cd94641 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 18:54:58 +0400 Subject: [PATCH 05/13] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectSportCar/ProjectSportCar/FormCarCollection.cs | 2 +- ProjectSportCar/ProjectSportCar/FormCarConfig.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/FormCarCollection.cs b/ProjectSportCar/ProjectSportCar/FormCarCollection.cs index badddec..bd89a05 100644 --- a/ProjectSportCar/ProjectSportCar/FormCarCollection.cs +++ b/ProjectSportCar/ProjectSportCar/FormCarCollection.cs @@ -53,7 +53,7 @@ public partial class FormCarCollection : Form /// Добавление автомобиля в коллекцию /// /// - private void SetCar(DrawningCar car) + private void SetCar(DrawningCar? car) { if (_company == null || car == null) { diff --git a/ProjectSportCar/ProjectSportCar/FormCarConfig.cs b/ProjectSportCar/ProjectSportCar/FormCarConfig.cs index 2f7855a..f6dc923 100644 --- a/ProjectSportCar/ProjectSportCar/FormCarConfig.cs +++ b/ProjectSportCar/ProjectSportCar/FormCarConfig.cs @@ -52,7 +52,7 @@ public partial class FormCarConfig : Form Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); Graphics gr = Graphics.FromImage(bmp); _car?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height); - _car?.SetPosition(5, 5); + _car?.SetPosition(15, 15); _car?.DrawTransport(gr); pictureBoxObject.Image = bmp; } From 509d2cb01061c36714ee48bc61af5ba29f3ce802 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 19:08:12 +0400 Subject: [PATCH 06/13] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectSportCar/ProjectSportCar/Entities/EntityCar.cs | 2 ++ ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ProjectSportCar/ProjectSportCar/Entities/EntityCar.cs b/ProjectSportCar/ProjectSportCar/Entities/EntityCar.cs index 12456a5..025dad5 100644 --- a/ProjectSportCar/ProjectSportCar/Entities/EntityCar.cs +++ b/ProjectSportCar/ProjectSportCar/Entities/EntityCar.cs @@ -37,4 +37,6 @@ public class EntityCar Weight = weight; BodyColor = bodyColor; } + + //TODO Прописать метод } \ No newline at end of file diff --git a/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs b/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs index db0900e..4972c1c 100644 --- a/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs +++ b/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs @@ -42,4 +42,6 @@ public class EntitySportCar : EntityCar Wing = wing; SportLine = sportLine; } + + //TODO Прописать метод } \ No newline at end of file From 3c43df8a4518f9c6f14592005190a5e7380f0f35 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 19:42:32 +0400 Subject: [PATCH 07/13] =?UTF-8?q?=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=80=D1=83=D0=B3=D0=B0=D0=BB=D0=BE=D1=81=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 2 +- .../ListGenericObjects.cs | 23 +++++++++++++++++-- .../ProjectSportCar/Drawnings/DrawningCar.cs | 9 ++++++++ .../Drawnings/DrawningSportCar.cs | 11 ++++++++- .../Entities/EntitySportCar.cs | 11 +++++++++ 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/AbstractCompany.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/AbstractCompany.cs index 85edb53..0753208 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/AbstractCompany.cs @@ -48,7 +48,7 @@ public abstract class AbstractCompany _pictureWidth = picWidth; _pictureHeight = picHeight; _collection = collection; - _collection.SetMaxCount = GetMaxCount; + _collection.MaxCount = GetMaxCount; } /// diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/ListGenericObjects.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/ListGenericObjects.cs index e6c0b2c..e8c5ae5 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/ListGenericObjects.cs @@ -1,4 +1,5 @@ -namespace ProjectSportCar.CollectionGenericObjects; + +namespace ProjectSportCar.CollectionGenericObjects; /// /// Параметризованный набор объектов @@ -19,7 +20,20 @@ public class ListGenericObjects : ICollectionGenericObjects public int Count => _collection.Count; - public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } } + public int MaxCount + { + get => _maxCount; + set + { + if (value > 0) + { + _maxCount = value; + } + } + } + + + public CollectionType GetCollectionType => throw new NotImplementedException(); /// /// Конструктор @@ -56,4 +70,9 @@ public class ListGenericObjects : ICollectionGenericObjects // TODO удаление объекта из списка return true; } + + public IEnumerable GetItems() + { + throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/ProjectSportCar/ProjectSportCar/Drawnings/DrawningCar.cs b/ProjectSportCar/ProjectSportCar/Drawnings/DrawningCar.cs index 570b5b6..e3f5302 100644 --- a/ProjectSportCar/ProjectSportCar/Drawnings/DrawningCar.cs +++ b/ProjectSportCar/ProjectSportCar/Drawnings/DrawningCar.cs @@ -84,6 +84,15 @@ public class DrawningCar EntityCar = new EntityCar(speed, weight, bodyColor); } + /// + /// Конструктор + /// + /// Класс-сущность + public DrawningCar(EntityCar car) : this() + { + // TODO продумать логику + } + /// /// Конструктор для наследников /// diff --git a/ProjectSportCar/ProjectSportCar/Drawnings/DrawningSportCar.cs b/ProjectSportCar/ProjectSportCar/Drawnings/DrawningSportCar.cs index 9bf7210..59bc69b 100644 --- a/ProjectSportCar/ProjectSportCar/Drawnings/DrawningSportCar.cs +++ b/ProjectSportCar/ProjectSportCar/Drawnings/DrawningSportCar.cs @@ -20,7 +20,16 @@ public class DrawningSportCar : DrawningCar public DrawningSportCar(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) : base(110, 60) { EntityCar = new EntitySportCar(speed, weight, bodyColor, additionalColor, bodyKit, wing, sportLine); - } + } + + /// + /// Конструктор + /// + /// Класс-сущность + public DrawningSportCar(EntityCar car) : base(110, 60) + { + // TODO продумать логику + } public override void DrawTransport(Graphics g) { diff --git a/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs b/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs index 4972c1c..d039499 100644 --- a/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs +++ b/ProjectSportCar/ProjectSportCar/Entities/EntitySportCar.cs @@ -44,4 +44,15 @@ public class EntitySportCar : EntityCar } //TODO Прописать метод + + /// + /// Создание объекта из массива строк + /// + /// + /// + public static EntitySportCar? CreateEntitySportCar(string[] strs) + { + // TODO продумать логику + return null; + } } \ No newline at end of file From 08ad72a781c3f04e6cd0cd04244125dba8034586 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 19:45:54 +0400 Subject: [PATCH 08/13] =?UTF-8?q?=D0=BE=D0=BF=D0=B5=D1=87=D0=B0=D1=82?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionGenericObjects/MassiveGenericObjects.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs index d7808a5..d39a0f8 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs @@ -49,7 +49,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects public bool Remove(int position) { // TODO проверка позиции - // TODO удаление объекта из массива, присовив элементу массива значение null + // TODO удаление объекта из массива, присвоив элементу массива значение null return true; } } \ No newline at end of file From e9cd7c75ce70ad71511275e4a2a0662b76e2d0e3 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 19:52:26 +0400 Subject: [PATCH 09/13] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D1=8B=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 --- .../ProjectSportCar/FormCarCollection.Designer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/FormCarCollection.Designer.cs b/ProjectSportCar/ProjectSportCar/FormCarCollection.Designer.cs index d00450d..f204ff8 100644 --- a/ProjectSportCar/ProjectSportCar/FormCarCollection.Designer.cs +++ b/ProjectSportCar/ProjectSportCar/FormCarCollection.Designer.cs @@ -68,7 +68,7 @@ groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Location = new Point(783, 24); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(179, 592); + groupBoxTools.Size = new Size(179, 608); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; @@ -82,7 +82,7 @@ panelCompanyTools.Controls.Add(buttonGoToCheck); panelCompanyTools.Dock = DockStyle.Bottom; panelCompanyTools.Enabled = false; - panelCompanyTools.Location = new Point(3, 336); + panelCompanyTools.Location = new Point(3, 352); panelCompanyTools.Name = "panelCompanyTools"; panelCompanyTools.Size = new Size(173, 253); panelCompanyTools.TabIndex = 9; @@ -249,7 +249,7 @@ pictureBox.Dock = DockStyle.Fill; pictureBox.Location = new Point(0, 24); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(783, 592); + pictureBox.Size = new Size(783, 608); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // @@ -297,7 +297,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(962, 616); + ClientSize = new Size(962, 632); Controls.Add(pictureBox); Controls.Add(groupBoxTools); Controls.Add(menuStrip); From e1a7ba4fd4dc8bc4f5ba19e97ec293498eb04193 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 20:27:29 +0400 Subject: [PATCH 10/13] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionGenericObjects/MassiveGenericObjects.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs index 82983b3..5b24776 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs @@ -26,7 +26,14 @@ public class MassiveGenericObjects : ICollectionGenericObjects { if (value > 0) { - _collection = new T?[value]; + if (_collection.Length > 0) + { + Array.Resize(ref _collection, value); + } + else + { + _collection = new T?[value]; + } } } } From c9d08e4cc6c3fa27a81e172aa97fdf59d32240d3 Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 20:35:57 +0400 Subject: [PATCH 11/13] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ListGenericObjects.cs | 7 ++++--- .../MassiveGenericObjects.cs | 15 +++++++-------- .../CollectionGenericObjects/StorageCollection.cs | 8 ++------ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/ListGenericObjects.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/ListGenericObjects.cs index d18992f..cda6e04 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/ListGenericObjects.cs @@ -46,14 +46,14 @@ public class ListGenericObjects : ICollectionGenericObjects public T? Get(int position) { // TODO проверка позиции - // TODO выборс ошибки, если выход за границы массива + // TODO выброс ошибки, если выход за границы массива return _collection[position]; } public bool Insert(T obj) { // TODO проверка, что не превышено максимальное количество элементов - // TODO выборс ошибки, если переполнение + // TODO выброс ошибки, если переполнение // TODO вставка в конец набора return true; } @@ -61,6 +61,7 @@ public class ListGenericObjects : ICollectionGenericObjects public bool Insert(T obj, int position) { // TODO проверка, что не превышено максимальное количество элементов + // TODO выброс ошибки, если переполнение // TODO проверка позиции // TODO вставка по позиции return true; @@ -69,7 +70,7 @@ public class ListGenericObjects : ICollectionGenericObjects public bool Remove(int position) { // TODO проверка позиции - // TODO выборс ошибки, если выход за границы массива + // TODO выброс ошибки, если выход за границы массива // TODO удаление объекта из списка return true; } diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs index e652407..10b6352 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs @@ -51,26 +51,26 @@ public class MassiveGenericObjects : ICollectionGenericObjects public T? Get(int position) { // TODO проверка позиции - // TODO выборс ошибки, если выход за границы массива - // TODO выборс ошибки, если объект пустой + // TODO выброс ошибки, если выход за границы массива + // TODO выброс ошибки, если объект пустой return _collection[position]; } public bool Insert(T obj) { // TODO вставка в свободное место набора - // TODO выборс ошибки, если переполнение + // TODO выброс ошибки, если переполнение return false; } public bool Insert(T obj, int position) { // TODO проверка позиции + // TODO выброс ошибки, если выход за границы массива // TODO проверка, что элемент массива по этой позиции пустой, если нет, то // ищется свободное место после этой позиции и идет вставка туда // если нет после, ищем до - // TODO выборс ошибки, если переполнение - // TODO выборс ошибки, если выход за границы массива + // TODO выброс ошибки, если переполнение // TODO вставка return false; } @@ -78,9 +78,8 @@ public class MassiveGenericObjects : ICollectionGenericObjects public bool Remove(int position) { // TODO проверка позиции - // TODO выборс ошибки, если выход за границы массива - // TODO выборс ошибки, если объект пустой - // TODO удаление объекта из массива, присовив элементу массива значение null + // TODO выброс ошибки, если выход за границы массива + // TODO выброс ошибки, если объект пустой // TODO удаление объекта из массива, присвоив элементу массива значение null return true; } diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/StorageCollection.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/StorageCollection.cs index 009398e..6ac1809 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/StorageCollection.cs @@ -174,12 +174,8 @@ public class StorageCollection } CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]); - ICollectionGenericObjects? collection = StorageCollection.CreateCollection(collectionType); - if (collection == null) - { - throw new Exception("Не удалось создать коллекцию"); - } - + ICollectionGenericObjects? collection = StorageCollection.CreateCollection(collectionType) ?? + throw new Exception("Не удалось определить тип коллекции:" + record[1]); collection.MaxCount = Convert.ToInt32(record[2]); string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries); From eff3a95bb3dc4b5cf38348c8c76e0798f726be0a Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 20:40:23 +0400 Subject: [PATCH 12/13] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=BA=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MassiveGenericObjects.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs index d39a0f8..8f69c05 100644 --- a/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectSportCar/ProjectSportCar/CollectionGenericObjects/MassiveGenericObjects.cs @@ -14,7 +14,23 @@ public class MassiveGenericObjects : ICollectionGenericObjects public int Count => _collection.Length; - public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } } + public int SetMaxCount + { + set + { + if (value > 0) + { + if (_collection.Length > 0) + { + Array.Resize(ref _collection, value); + } + else + { + _collection = new T?[value]; + } + } + } + } /// /// Конструктор From c11253c6f4afe901d66577cd30d9e9508014078d Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 21:08:54 +0400 Subject: [PATCH 13/13] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSportCar/Exceptions/CollectionOverflowException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectSportCar/ProjectSportCar/Exceptions/CollectionOverflowException.cs b/ProjectSportCar/ProjectSportCar/Exceptions/CollectionOverflowException.cs index 57f86a2..2f413a2 100644 --- a/ProjectSportCar/ProjectSportCar/Exceptions/CollectionOverflowException.cs +++ b/ProjectSportCar/ProjectSportCar/Exceptions/CollectionOverflowException.cs @@ -8,7 +8,7 @@ namespace ProjectSportCar.Exceptions; [Serializable] internal class CollectionOverflowException : ApplicationException { - public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: count" + count) { } + public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: " + count) { } public CollectionOverflowException() : base() { }