исправленно
This commit is contained in:
parent
6e509b6d07
commit
f5df18ed71
@ -49,9 +49,9 @@ namespace WarmlyShip
|
||||
public Bitmap ShowOnMap()
|
||||
{
|
||||
Shaking();
|
||||
foreach (var car in _setShips.GetShips())
|
||||
foreach (var ship in _setShips.GetShips())
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, car);
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, ship);
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
|
@ -20,47 +20,15 @@ namespace WarmlyShip
|
||||
_places = new List<T>();
|
||||
}
|
||||
|
||||
private bool CanInsert(int position)
|
||||
{
|
||||
for (int i = position; i < Count; ++i)
|
||||
if (_places[i] == null) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int Insert(T ship)
|
||||
{
|
||||
if (CanInsert(0))
|
||||
{
|
||||
for (int i = Count - 1; i > 0; --i)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
_places[i - 1] = null;
|
||||
}
|
||||
}
|
||||
_places[0] = ship;
|
||||
_places.Insert(0, ship);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Insert(T ship, int position)
|
||||
{
|
||||
if (position < 0 || position > Count || Count == _maxCount) return 0;
|
||||
/*if (_places[position] != null && CanInsert(position))
|
||||
{
|
||||
for (int i = _places.Count - 1; i > position; --i)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
_places[i - 1] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
_places[position] = ship;
|
||||
return 1;*/
|
||||
_places.Insert(position, ship);
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user