Kashin M.I. Lab work 8 #8

Closed
Sosees04ka wants to merge 6 commits from LabWork08 into LabWork07
Showing only changes of commit e8a4f802de - Show all commits

View File

@ -19,15 +19,7 @@ namespace GasolineTanker
}
public int Insert(T gasolineTanker)
{
if (_places.Count < _maxCount)
{
_places.Add(gasolineTanker);
for (int i = 0; i < _places.Count; i++)
{
if (_places[i] == gasolineTanker) return i;
}
}
return -1;
return Insert(gasolineTanker, 0);
}
private bool isCorrectPosition(int position)
{
@ -36,7 +28,7 @@ namespace GasolineTanker
public int Insert(T gasolineTanker, int position)
{
if (_places.Contains(gasolineTanker))
throw new ArgumentException($"Объект {gasolineTanker} уже есть в наборе");
throw new ArgumentException($"The {gasolineTanker} object is already in the set");
if (Count == _maxCount)
throw new StorageOverflowException(_maxCount);
if (!isCorrectPosition(position))