LabWork_04 #7

Closed
maxnes3 wants to merge 7 commits from LabWork_04 into LabWork_03
2 changed files with 4 additions and 36 deletions
Showing only changes of commit f5df18ed71 - Show all commits

View File

@ -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);
}

View File

@ -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;
return 1;
}
return 0;
_places.Insert(0, ship);
return 1;
}
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;
}