fix conflict

This commit is contained in:
Казначеева Елизавета 2023-11-20 20:24:50 +04:00
parent f880341709
commit fe3868fac1

View File

@ -6,10 +6,7 @@ using System.Threading.Tasks;
namespace Battleship.Generics namespace Battleship.Generics
{ {
<<<<<<< HEAD
=======
>>>>>>> 504798d4c4853a3db22a25ff6cf613a36640f1c3
internal class SetGeneric<T> internal class SetGeneric<T>
where T : class where T : class
{ {
@ -24,46 +21,8 @@ namespace Battleship.Generics
public bool Insert(T ship) public bool Insert(T ship)
{ {
<<<<<<< HEAD
if(_places.Count == _maxCount) if(_places.Count == _maxCount)
{ {
=======
if (_places[Count - 1] != null)
return -1;
return Insert(ship,0);
}
/// <summary>
/// Добавление объекта в набор на конкретную позицию
/// /// </summary>
/// <param name="car">Добавляемый автомобиль</param>
/// <param name="position">Позиция</param>
/// <returns></returns>
public int Insert(T ship, int position)
{
if (!(position >= 0 && position < Count))
return -1;
if (_places[position] != null)
{
int ind = position;
while (ind < Count && _places[ind] != null)
ind++;
if (ind == Count)
return -1;
for (int i = ind - 1; i >= position; i--)
_places[i + 1] = _places[i];
}
_places[position] = ship;
return position;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public bool Remove(int position)
{
if (!(position >= 0 && position < Count) || _places[position] == null)
>>>>>>> 504798d4c4853a3db22a25ff6cf613a36640f1c3
return false; return false;
} }
Insert(ship, 0); Insert(ship, 0);
@ -72,7 +31,6 @@ namespace Battleship.Generics
public bool Insert(T ship, int position) public bool Insert(T ship, int position)
{ {
<<<<<<< HEAD
if(!(position >= 0 && position <= Count && _places.Count < _maxCount)) if(!(position >= 0 && position <= Count && _places.Count < _maxCount))
{ {
return false; return false;
@ -119,11 +77,6 @@ namespace Battleship.Generics
} }
} }
=======
if (!(position >= 0 && position < Count))
return null;
return _places[position];
>>>>>>> 504798d4c4853a3db22a25ff6cf613a36640f1c3
} }
} }
} }