From e38cf2d1eccf7f09acdaa20c204da556cac4a581 Mon Sep 17 00:00:00 2001 From: Azamat Date: Sun, 19 May 2024 18:20:28 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=B0=D1=82:=20e5ff429fd0079?= =?UTF-8?q?6353d4b32b6b19c3400e18d4ff0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICollectionGenericObjects.cs | 6 ++---- .../ListGenericObjects.cs | 4 ++-- .../MassiveGenericObjects.cs | 5 +++-- MotorBoat/MotorBoat/FormBoatCollection.cs | 8 ++++++++ MotorBoat/MotorBoat/MotorBoat.csproj | 15 +++++---------- MotorBoat/MotorBoat/Program.cs | 2 +- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/MotorBoat/MotorBoat/CollectionGenericObjects/ICollectionGenericObjects.cs b/MotorBoat/MotorBoat/CollectionGenericObjects/ICollectionGenericObjects.cs index 64249fb..a0b9bad 100644 --- a/MotorBoat/MotorBoat/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/MotorBoat/MotorBoat/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -18,17 +18,15 @@ public interface ICollectionGenericObjects /// Добавление объекта в коллекцию /// /// Добавляемый объект - /// Сравнение двух объектов /// true - вставка прошла удачно, false - вставка не удалась - int Insert(T obj, IEqualityComparer? comparer = null); + int Insert(T obj); /// /// Добавление объекта в коллекцию на конкретную позицию /// /// Добавляемый объект - /// Сравнение двух объектов /// Позиция /// true - вставка прошла удачно, false - вставка не удалась - int Insert(T obj, int position, IEqualityComparer? comparer = null); + int Insert(T obj, int position); /// /// Удаление объекта из коллекции с конкретной позиции /// diff --git a/MotorBoat/MotorBoat/CollectionGenericObjects/ListGenericObjects.cs b/MotorBoat/MotorBoat/CollectionGenericObjects/ListGenericObjects.cs index d1ace47..c2511c2 100644 --- a/MotorBoat/MotorBoat/CollectionGenericObjects/ListGenericObjects.cs +++ b/MotorBoat/MotorBoat/CollectionGenericObjects/ListGenericObjects.cs @@ -51,14 +51,14 @@ public class ListGenericObjects : ICollectionGenericObjects if (_collection[position] == null) throw new ObjectNotFoundException(); return _collection[position]; } - public int Insert(T obj, IEqualityComparer? comparer = null) + public int Insert(T obj) { if (Count == _maxCount) throw new CollectionOverflowException(Count); _collection.Add(obj); return Count; } - public int Insert(T obj, int position, IEqualityComparer? comparer = null) + public int Insert(T obj, int position) { if (Count == _maxCount) throw new CollectionOverflowException(Count); if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position); diff --git a/MotorBoat/MotorBoat/CollectionGenericObjects/MassiveGenericObjects.cs b/MotorBoat/MotorBoat/CollectionGenericObjects/MassiveGenericObjects.cs index 4aebfc4..dcf7e29 100644 --- a/MotorBoat/MotorBoat/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/MotorBoat/MotorBoat/CollectionGenericObjects/MassiveGenericObjects.cs @@ -44,7 +44,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects if (position < 0 || position >= Count) throw new PositionOutOfCollectionException(); return _collection[position]; } - public int Insert(T obj, IEqualityComparer? comparer = null) + public int Insert(T obj) { for (int i = 0; i < Count; i++) { @@ -56,7 +56,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects } throw new CollectionOverflowException(); } - public int Insert(T obj, int position, IEqualityComparer? comparer = null) + public int Insert(T obj, int position) { if (position < 0 || position >= Count) { @@ -66,6 +66,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects { _collection[position] = obj; return position; + } int temp = position + 1; while (temp < Count) diff --git a/MotorBoat/MotorBoat/FormBoatCollection.cs b/MotorBoat/MotorBoat/FormBoatCollection.cs index 2e03780..a2b7521 100644 --- a/MotorBoat/MotorBoat/FormBoatCollection.cs +++ b/MotorBoat/MotorBoat/FormBoatCollection.cs @@ -46,6 +46,10 @@ public partial class FormBoatCollection : Form /// private void ButtonAddBoat_Click(object sender, EventArgs e) { + if (_company == null) + { + return; + } FormBoatConfig form = new(); form.AddEvent(SetBoat); form.Show(); @@ -195,6 +199,10 @@ public partial class FormBoatCollection : Form /// private void ButtonCollectionDel_Click(object sender, EventArgs e) { + // TODO прописать логику удаления элемента из коллекции + // нужно убедиться, что есть выбранная коллекция + // спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись + // удалить и обновить ListBox if (listBoxCollection.SelectedIndex < 0) { MessageBox.Show("Коллекция не выбрана"); diff --git a/MotorBoat/MotorBoat/MotorBoat.csproj b/MotorBoat/MotorBoat/MotorBoat.csproj index 5998afe..f60d5d4 100644 --- a/MotorBoat/MotorBoat/MotorBoat.csproj +++ b/MotorBoat/MotorBoat/MotorBoat.csproj @@ -9,15 +9,9 @@ - - - - + - - - @@ -29,9 +23,10 @@ - - Always - + + ResXFileCodeGenerator + Resources.Designer.cs + \ No newline at end of file diff --git a/MotorBoat/MotorBoat/Program.cs b/MotorBoat/MotorBoat/Program.cs index 5cfefd8..8428796 100644 --- a/MotorBoat/MotorBoat/Program.cs +++ b/MotorBoat/MotorBoat/Program.cs @@ -42,4 +42,4 @@ namespace MotorBoat }); } } -} \ No newline at end of file +} \ No newline at end of file