Готовая 8 лаба
This commit is contained in:
parent
a8bc30a079
commit
409f14e146
@ -12,6 +12,7 @@ using Tank.MovementStrategy;
|
|||||||
using Tank.Generics;
|
using Tank.Generics;
|
||||||
using Tank.Exceptions;
|
using Tank.Exceptions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace Tank
|
namespace Tank
|
||||||
{
|
{
|
||||||
@ -56,20 +57,26 @@ namespace Tank
|
|||||||
}
|
}
|
||||||
_logger.LogInformation("Начало попытки добавления объекта");
|
_logger.LogInformation("Начало попытки добавления объекта");
|
||||||
|
|
||||||
|
try
|
||||||
if ((obj + tank) != false)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
if ((obj + tank) != false)
|
||||||
pictureBoxCollection.Image = obj.ShowTanks();
|
{
|
||||||
_logger.LogInformation($"Добавлен объект {obj}");
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowTanks();
|
||||||
|
_logger.LogInformation($"Добавлен объект {obj}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (TankStorageOverflowException ex)
|
||||||
{
|
{
|
||||||
TankStorageOverflowException ex = new TankStorageOverflowException();
|
|
||||||
MessageBox.Show(ex.Message);
|
MessageBox.Show(ex.Message);
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
_logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}");
|
_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)
|
private void ButtonAddArmoredCar_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace Tank.Generics
|
|||||||
throw new TankStorageOverflowException(_maxCount);
|
throw new TankStorageOverflowException(_maxCount);
|
||||||
|
|
||||||
if (equal != null && _places.Contains<T>(tank, equal))
|
if (equal != null && _places.Contains<T>(tank, equal))
|
||||||
throw new ApplicationException("Уже есть");
|
throw new ApplicationException("Такой объект уже есть.");
|
||||||
|
|
||||||
_places.Insert(0, tank);
|
_places.Insert(0, tank);
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using Tank.MovementStrategy;
|
using Tank.MovementStrategy;
|
||||||
using Tank.DrawingObjects;
|
using Tank.DrawingObjects;
|
||||||
using Tank.MovementStrategy;
|
using Tank.MovementStrategy;
|
||||||
|
using Tank.Drawings;
|
||||||
|
|
||||||
namespace Tank.Generics
|
namespace Tank.Generics
|
||||||
{
|
{
|
||||||
@ -67,7 +68,7 @@ namespace Tank.Generics
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (bool)collect?._collection.Insert(obj);
|
return (bool)collect?._collection.Insert(obj, new DrawiningTankEqutables());
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора вычитания
|
/// Перегрузка оператора вычитания
|
||||||
|
Loading…
x
Reference in New Issue
Block a user