fix conflict
This commit is contained in:
commit
f880341709
@ -6,6 +6,10 @@ 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
|
||||||
{
|
{
|
||||||
@ -20,8 +24,46 @@ 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);
|
||||||
@ -30,6 +72,7 @@ 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;
|
||||||
@ -76,6 +119,11 @@ namespace Battleship.Generics
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
if (!(position >= 0 && position < Count))
|
||||||
|
return null;
|
||||||
|
return _places[position];
|
||||||
|
>>>>>>> 504798d4c4853a3db22a25ff6cf613a36640f1c3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user