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

This commit is contained in:
platoff aeeee 2023-11-08 10:58:56 +04:00
parent b906b3f880
commit 431f46b2bb
2 changed files with 7 additions and 2 deletions

View File

@ -31,6 +31,8 @@ namespace Tank.Generics
{
if (position < 0 || position > _maxCount)
return false;
if (Count >= _maxCount)
return false;
_places.Insert(0, tank);
return true;
}
@ -46,7 +48,7 @@ namespace Tank.Generics
{
get
{
if (position < 0)
if (position < 0 || position > _maxCount)
{
return null;
}
@ -54,13 +56,14 @@ namespace Tank.Generics
}
set
{
if (position < 0)
if (position < 0 || position > _maxCount)
{
return;
}
_places[position] = value;
}
}
public IEnumerable<T?> GetTanks(int? maxTanks = null)
{
for (int i = 0; i < _places.Count; ++i)

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Tank.Generics;
using Tank.DrawingObjects;
using Tank.MovementStrategy;
using System.Globalization;
namespace Tank.Generics
{
@ -84,5 +85,6 @@ namespace Tank.Generics
return null;
}
}
}
}