Sorokin P.V. Lab work 4 #4

Merged
eegov merged 5 commits from LabWork04 into LabWork03 2022-10-28 08:55:22 +04:00
Showing only changes of commit 2d1622a1b6 - Show all commits

View File

@ -19,21 +19,17 @@ namespace Liner
}
public int Insert(T ship)
{
if (_places.Count > _maxCount)
{
return -1;
}
return Insert(ship, 0);
}
public int Insert(T ship, int position)
{
if (position >= _maxCount || position < 0) return -1;
if (position < 0 || position > Count || _maxCount == Count) return -1;
_places.Insert(position, ship);
return position;
}
public T Remove(int position)
{
if (position >= _maxCount || position < 0)
if (position >= Count || position < 0)
{
return null;
}
@ -45,7 +41,7 @@ namespace Liner
{
get
{
if (position >= _places.Count || position < 0)
if (position >= Count || position < 0)
{
return null;
}
@ -53,7 +49,7 @@ namespace Liner
}
set
{
if (position >= _places.Count || position < 0)
if (position >= Count || position < 0)
{
return;
}