diff --git a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs index aca2892..d5ddb84 100644 --- a/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs +++ b/WarmlyLocomotive/WarmlyLocomotive/MapWithSetLocomotivesGeneric.cs @@ -25,7 +25,7 @@ namespace WarmlyLocomotive /// /// Размер занимаемого объектом места (высота) /// - private readonly int _placeSizeHeight = 120 /*105*/; + private readonly int _placeSizeHeight = 120; /// /// Набор объектов /// @@ -149,19 +149,20 @@ namespace WarmlyLocomotive Brush brushLightGray = new SolidBrush(Color.LightGray); Brush brushBrown = new SolidBrush(Color.Brown); g.FillRectangle(brushLightGray, 0, 0, _pictureWidth, _pictureHeight); - for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + int placesInRow = _pictureWidth / (_placeSizeWidth + 30); + for (int i = 0; i < placesInRow; i++) { for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) {//линия рамзетки места if (j != 0) { - int x = i * (_placeSizeWidth + 30); - g.DrawLine(penTwo, x, j * _placeSizeHeight, x + _placeSizeWidth - 20, j * _placeSizeHeight); - g.DrawLine(penTwo, x, j * _placeSizeHeight - 20, x + _placeSizeWidth - 20, j * _placeSizeHeight - 20); + int xForRail = i * (_placeSizeWidth + 30); + g.DrawLine(penTwo, xForRail, j * _placeSizeHeight, xForRail + _placeSizeWidth - 20, j * _placeSizeHeight); + g.DrawLine(penTwo, xForRail, j * _placeSizeHeight - 20, xForRail + _placeSizeWidth - 20, j * _placeSizeHeight - 20); for (int k = 0; k < (_placeSizeWidth - 20) / 15; ++k) { - g.FillRectangle(brushBrown, x, j * _placeSizeHeight - 20, 5, 20); - x += 15; + g.FillRectangle(brushBrown, xForRail, j * _placeSizeHeight - 20, 5, 20); + xForRail += 15; } } g.DrawLine(pen, i * (_placeSizeWidth + 30), j * _placeSizeHeight + 10, i * (_placeSizeWidth + 30) + _placeSizeWidth / 2, j * _placeSizeHeight + 10); @@ -175,23 +176,23 @@ namespace WarmlyLocomotive /// private void DrawLocomotives(Graphics g) { - int x = 2; - int y = 10; + int xForLocomotive = 2; + int yForLocomotive = 10; int countInRow = 0; for (int i = 0; i < _setLocomotives.Count; i++) { - if (countInRow >= _pictureWidth / _placeSizeWidth) + if (countInRow >= _pictureWidth / (_placeSizeWidth + 30)) { - x = 2; - y += _placeSizeHeight; + xForLocomotive = 2; + yForLocomotive += _placeSizeHeight; countInRow = 0; } if (_setLocomotives.Get(i) != null) { - var locomotive = _setLocomotives.Get(i); - locomotive.SetObject(x, y, _pictureWidth, _pictureHeight); + T locomotive = _setLocomotives.Get(i); + locomotive.SetObject(xForLocomotive, yForLocomotive, _pictureWidth, _pictureHeight); locomotive.DrawningObject(g); - x += _placeSizeWidth + 30; + xForLocomotive += _placeSizeWidth + 30; countInRow++; } } diff --git a/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs b/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs index 156b343..eec3dba 100644 --- a/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs +++ b/WarmlyLocomotive/WarmlyLocomotive/SetLocomotivesGeneric.cs @@ -32,7 +32,6 @@ namespace WarmlyLocomotive /// public int Insert(T locomotive) { - // TODO вставка в начало набора bool hasEmptySpace = false; int indexOfEmptyPlace = 0; for (int i = 0; i < Count; ++i) @@ -61,16 +60,11 @@ namespace WarmlyLocomotive /// /// Добавление объекта в набор на конкретную позицию /// - /// Добавляемый локомотив + /// Добавляемый локомотив /// Позиция /// public int Insert(T locomotive, int position) { - // TODO проверка позиции - // TODO проверка, что элемент массива по этой позиции пустой, если нет, то - // проверка, что после вставляемого элемента в массиве есть пустой элемент - // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента - // TODO вставка по позиции if (position < 0 || position >= Count) { return -1; @@ -115,8 +109,6 @@ namespace WarmlyLocomotive /// public T Remove(int position) { - // TODO проверка позиции - // TODO удаление объекта из массива, присовив элементу массива значение null if (position < 0 || position >= Count) { return null; @@ -132,7 +124,6 @@ namespace WarmlyLocomotive /// public T Get(int position) { - // TODO проверка позиции if (position < 0 || position >= Count) { return null;