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