This commit is contained in:
Daria 2024-04-29 12:41:53 +04:00
parent daf02bad9d
commit 9a22658047
4 changed files with 12 additions and 16 deletions

View File

@ -72,14 +72,9 @@ public abstract class AbstractCompany
/// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns>
public static bool operator -(AbstractCompany company, int pos)
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
{
DrawningTrackedVehicle? obj = company._collection.Get(pos);
if (obj != null)
{
company._collection.Remove(pos);
}
return false;
return company._collection?.Remove(position) ?? null;
}
/// <summary>
/// Получение случайного объекта из коллекции

View File

@ -37,7 +37,7 @@ public interface ICollectionGenericObjects<T>
/// </summary>
/// <param name="position">Позиция</param>
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
bool Remove(int position);
T? Remove(int position);
/// <summary>
/// Получение объекта по позиции

View File

@ -49,12 +49,12 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
return 1;
}
public bool Remove(int position)
public T? Remove(int position)
{
if (!(position >= 0 && position < Count))
return false;
if (position < 0 || position > Count) return null;
T? pos = _collection[position];
_collection.RemoveAt(position);
return true;
return pos;
}

View File

@ -78,15 +78,16 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
return position;
}
public bool Remove(int position)
public T Remove(int position)
{
if (position < 0 || position > Count)
{
return false;
return null;
}
T drawningTrackedVehicle = _collection[position];
_collection[position] = null;
return true;
return drawningTrackedVehicle;
}
}