Откат: e5ff429fd00796353d4b32b6b19c3400e18d4ff0

This commit is contained in:
Azamat 2024-05-19 18:20:28 +04:00
parent e5ff429fd0
commit e38cf2d1ec
6 changed files with 21 additions and 19 deletions

View File

@ -18,17 +18,15 @@ public interface ICollectionGenericObjects<T>
/// Добавление объекта в коллекцию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <param name="comparer"> Сравнение двух объектов </param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj, IEqualityComparer<T?>? comparer = null);
int Insert(T obj);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <param name="comparer"> Сравнение двух объектов </param>
/// <param name="position">Позиция</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null);
int Insert(T obj, int position);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
/// </summary>

View File

@ -51,14 +51,14 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
if (_collection[position] == null) throw new ObjectNotFoundException();
return _collection[position];
}
public int Insert(T obj, IEqualityComparer<T?>? 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<T?>? 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);

View File

@ -44,7 +44,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
if (position < 0 || position >= Count) throw new PositionOutOfCollectionException();
return _collection[position];
}
public int Insert(T obj, IEqualityComparer<T?>? comparer = null)
public int Insert(T obj)
{
for (int i = 0; i < Count; i++)
{
@ -56,7 +56,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
}
throw new CollectionOverflowException();
}
public int Insert(T obj, int position, IEqualityComparer<T?>? comparer = null)
public int Insert(T obj, int position)
{
if (position < 0 || position >= Count)
{
@ -66,6 +66,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
{
_collection[position] = obj;
return position;
}
int temp = position + 1;
while (temp < Count)

View File

@ -46,6 +46,10 @@ public partial class FormBoatCollection : Form
/// <param name="e"></param>
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
/// <param name="e"></param>
private void ButtonCollectionDel_Click(object sender, EventArgs e)
{
// TODO прописать логику удаления элемента из коллекции
// нужно убедиться, что есть выбранная коллекция
// спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись
// удалить и обновить ListBox
if (listBoxCollection.SelectedIndex < 0)
{
MessageBox.Show("Коллекция не выбрана");

View File

@ -9,15 +9,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.10" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
@ -29,9 +23,10 @@
</ItemGroup>
<ItemGroup>
<None Update="serilogConfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -42,4 +42,4 @@ namespace MotorBoat
});
}
}
}
}<EFBFBD>