Готовая 7 лаба
This commit is contained in:
parent
4b3d7d9694
commit
5c23c80066
@ -56,20 +56,22 @@ namespace Tank
|
|||||||
}
|
}
|
||||||
_logger.LogInformation("Начало попытки добавления объекта");
|
_logger.LogInformation("Начало попытки добавления объекта");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if ((obj + tank) != false)
|
if ((obj + tank) != false)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBoxCollection.Image = obj.ShowTanks();
|
pictureBoxCollection.Image = obj.ShowTanks();
|
||||||
_logger.LogInformation($"Добавлен объект {obj}");
|
_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} ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void ButtonAddArmoredCar_Click(object sender, EventArgs e)
|
private void ButtonAddArmoredCar_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Tank.Exceptions;
|
||||||
|
|
||||||
namespace Tank.Generics
|
namespace Tank.Generics
|
||||||
{
|
{
|
||||||
@ -29,10 +30,10 @@ namespace Tank.Generics
|
|||||||
|
|
||||||
public bool Insert(T tank, int position)
|
public bool Insert(T tank, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > _maxCount)
|
if (position < 0 || position >= _maxCount)
|
||||||
return false;
|
throw new TankNotFoundException(position);
|
||||||
if (Count >= _maxCount)
|
if (Count >= _maxCount)
|
||||||
return false;
|
throw new TankStorageOverflowException(_maxCount);
|
||||||
_places.Insert(0, tank);
|
_places.Insert(0, tank);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user