diff --git a/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs b/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs index 655f208..3efe986 100644 --- a/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs +++ b/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs @@ -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); } diff --git a/WarmlyShip/WarmlyShip/SetShipGeneric.cs b/WarmlyShip/WarmlyShip/SetShipGeneric.cs index 2740f09..d5d72d1 100644 --- a/WarmlyShip/WarmlyShip/SetShipGeneric.cs +++ b/WarmlyShip/WarmlyShip/SetShipGeneric.cs @@ -20,47 +20,15 @@ namespace WarmlyShip _places = new List(); } - 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; }