This commit is contained in:
ShabOl 2023-11-29 10:24:28 +04:00
parent b1f9c38b44
commit f49703596b
3 changed files with 25 additions and 20 deletions

View File

@ -51,18 +51,26 @@ namespace AirBomber
if (obj is null)
return;
if (obj + (Renderer) != -1)
try
{
MessageBox.Show("Объект добавлен");
_logger.LogInformation("Объект добавлен");
if (obj + (Renderer) != -1)
{
MessageBox.Show("Объект добавлен");
_logger.LogInformation("Объект добавлен");
CollectionPictureBox.Image = obj.ShowEntities();
CollectionPictureBox.Image = obj.ShowEntities();
}
else
{
MessageBox.Show("Не удалось добавить объект");
_logger.LogWarning("Не удалось добавить объект");
}
}
else
catch (StorageOverflowException ex)
{
MessageBox.Show("Не удалось добавить объект");
_logger.LogWarning("Не удалось добавить объект");
MessageBox.Show(ex.Message);
_logger.LogWarning(ex.Message);
}
}
@ -97,6 +105,7 @@ namespace AirBomber
catch (EntityNotFoundException ex)
{
MessageBox.Show(ex.Message);
_logger.LogWarning(ex.Message);
}
}

View File

@ -1,4 +1,5 @@
using AirBomber.MovementStrategy;
using AirBomber.Exceptions;
using AirBomber.MovementStrategy;
using AirBomber.Rendering;
namespace AirBomber.Generics
@ -36,12 +37,7 @@ namespace AirBomber.Generics
public static bool operator -(EntitiesGenericCollection<T, U> collect, int pos)
{
T? obj = collect._collection[pos];
if (obj != null)
return collect._collection.Remove(pos);
return false;
return collect._collection.Remove(pos);
}
public U? GetU(int pos)

View File

@ -29,13 +29,13 @@ namespace AirBomber.Generics
return i;
}
throw new StorageOverflowException();
throw new StorageOverflowException(_maxCount);
}
public int Insert(T Entity, int Position)
{
if (Position >= _maxCount)
throw new StorageOverflowException();
throw new StorageOverflowException(_maxCount);
if (_objects[Position] is null)
{
@ -43,16 +43,16 @@ namespace AirBomber.Generics
return Position;
}
throw new StorageOverflowException();
throw new StorageOverflowException(_maxCount);
}
public bool Remove(int Position)
{
if (Position >= _maxCount)
throw new EntityNotFoundException();
throw new EntityNotFoundException(Position);
if (_objects[Position] is null)
throw new EntityNotFoundException();
throw new EntityNotFoundException(Position);
_objects[Position] = default(T);
return true;