Готовая 8 лаба

This commit is contained in:
platoff aeeee 2023-12-25 00:44:28 +04:00
parent a8bc30a079
commit 409f14e146
3 changed files with 17 additions and 9 deletions

View File

@ -12,6 +12,7 @@ using Tank.MovementStrategy;
using Tank.Generics;
using Tank.Exceptions;
using Microsoft.Extensions.Logging;
using System.Linq.Expressions;
namespace Tank
{
@ -56,20 +57,26 @@ namespace Tank
}
_logger.LogInformation("Начало попытки добавления объекта");
try
{
if ((obj + tank) != false)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowTanks();
_logger.LogInformation($"Добавлен объект {obj}");
}
else
}
catch (TankStorageOverflowException ex)
{
TankStorageOverflowException ex = new TankStorageOverflowException();
MessageBox.Show(ex.Message);
MessageBox.Show("Не удалось добавить объект");
_logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}");
}
catch (ApplicationException ex)
{
MessageBox.Show(ex.Message);
_logger.LogWarning($"Не удалось добавить объект: {ex.Message}");
}
}
private void ButtonAddArmoredCar_Click(object sender, EventArgs e)
{

View File

@ -38,7 +38,7 @@ namespace Tank.Generics
throw new TankStorageOverflowException(_maxCount);
if (equal != null && _places.Contains<T>(tank, equal))
throw new ApplicationException("Уже есть");
throw new ApplicationException("Такой объект уже есть.");
_places.Insert(0, tank);
return true;

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Tank.MovementStrategy;
using Tank.DrawingObjects;
using Tank.MovementStrategy;
using Tank.Drawings;
namespace Tank.Generics
{
@ -67,7 +68,7 @@ namespace Tank.Generics
{
return false;
}
return (bool)collect?._collection.Insert(obj);
return (bool)collect?._collection.Insert(obj, new DrawiningTankEqutables());
}
/// <summary>
/// Перегрузка оператора вычитания