Изменения

This commit is contained in:
crum61kg 2023-01-23 00:00:11 +04:00
parent 68db88d4c4
commit c7de4f3d1d
3 changed files with 26 additions and 42 deletions

View File

@ -164,10 +164,13 @@ namespace WarmlyShip
/// <param name="g"></param>
private void DrawWarmlyShip(Graphics g)
{
int width = _pictureWidth / _placeSizeWidth;
int k = 0;
foreach (var ship in _setWarmlyShip.GetShip())
{
// TODO установка позиции
ship.SetObject(k % width * _placeSizeWidth + 10, k / width * _placeSizeHeight + 20, _pictureWidth, _pictureHeight);
ship.DrawningObject(g);
k++;
}
}

View File

@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace WarmlyShip
{
/// <summary>
/// Класс для хранения коллекции карт
/// </summary>
internal class MapsCollection
{
/// <summary>
@ -42,7 +45,8 @@ namespace WarmlyShip
/// <param name="map">Карта</param>
public void AddMap(string name, AbstractMap map)
{
if (!Keys.Contains(name))
_mapStorages.Add(name, new MapWithSetWarmlyShipGeneric<DrawningObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
}
/// <summary>
/// Удаление карты
@ -50,7 +54,8 @@ namespace WarmlyShip
/// <param name="name">Название карты</param>
public void DelMap(string name)
{
// TODO Прописать логику для удаления
if (Keys.Contains(name))
_mapStorages.Remove(name);
}
/// <summary>
/// Доступ к парковке
@ -62,10 +67,10 @@ namespace WarmlyShip
{
get
{
// TODO Продумать логику получения объекта
if (Keys.Contains(ind))
return _mapStorages[ind];
return null;
}
}
}
}

View File

@ -39,18 +39,9 @@ namespace WarmlyShip
/// <returns></returns>
public int Insert(T ship)
{
// + проверка на _maxCount
if (ship == null)
{
return -1;
}
for (int i = Count - 1; i > 0; i--)
{
_places[i] = _places[i - 1];
}
_places[0] = ship;
return 0;
if (Count < _maxCount)
return Insert(ship, 0);
return -1;
}
/// <summary>
/// Добавление объекта в набор на конкретную позицию
@ -60,27 +51,12 @@ namespace WarmlyShip
/// <returns></returns>
public int Insert(T ship, int position)
{
//кое что убрать (проверка позиции)
if (position < 0 || position > Count)
{
return -1;
}
int firstNullElementIndex = position;
while (_places[firstNullElementIndex] != null)
{
if (firstNullElementIndex >= Count)
{
return -1;
}
firstNullElementIndex++;
}
for (int i = firstNullElementIndex; i > position; i--)
{
_places[i] = _places[i - 1];
}
_places[position] = ship;
return 0;
_places.Insert(position, ship);
return position;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
@ -89,14 +65,12 @@ namespace WarmlyShip
/// <returns></returns>
public T Remove(int position)
{
// убрать удаление объекта
if (_places[position] == null)
{
if (position < 0 || position >= Count)
return null;
}
var result = _places[position];
_places[position] = null;
_places.RemoveAt(position);
return result;
}
/// <summary>
/// Получение объекта из набора по позиции
@ -107,13 +81,15 @@ namespace WarmlyShip
{
get
{
// TODO проверка позиции
if (position < 0 || position >= Count)
return null;
return _places[position];
}
set
{
// TODO проверка позиции
// TODO вставка в список по позиции
if (position < 0 || position >= _maxCount)
return;
_places.Add(value);
}
}
/// <summary>