From 578ac2e424c18e2e19aee1c0d45bcfcee0d1eecc Mon Sep 17 00:00:00 2001 From: qkrlnt Date: Wed, 27 Mar 2024 18:41:43 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D0=B8?= =?UTF-8?q?=D0=B7=20=D1=82=D1=80=D0=B5=D0=B1=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=E2=84=965?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionGenericObjects/AbstractCompany.cs | 2 +- .../ICollectionGenericObjects.cs | 2 +- .../MassiveGenericObjects.cs | 12 ++++++------ .../CollectionGenericObjects/TrainSharingService.cs | 4 ++-- ProjectMonorail/FormTrainCollection.cs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ProjectMonorail/CollectionGenericObjects/AbstractCompany.cs b/ProjectMonorail/CollectionGenericObjects/AbstractCompany.cs index ee17661..2c96fb1 100644 --- a/ProjectMonorail/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectMonorail/CollectionGenericObjects/AbstractCompany.cs @@ -67,7 +67,7 @@ public abstract class AbstractCompany { if(company._collection == null) { - return 0; + return -1; } return company._collection.Insert(train); } diff --git a/ProjectMonorail/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectMonorail/CollectionGenericObjects/ICollectionGenericObjects.cs index 23a8e97..2f88cf7 100644 --- a/ProjectMonorail/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectMonorail/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -36,7 +36,7 @@ public interface ICollectionGenericObjects /// Добавляемый объект /// Позиция /// true - вставка прошла удачно, false - вставка не удалась - bool Insert(T obj, int position); + int Insert(T obj, int position); /// /// Удаление объекта из коллекции с конкретной позиции diff --git a/ProjectMonorail/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectMonorail/CollectionGenericObjects/MassiveGenericObjects.cs index 2efbf02..f008b63 100644 --- a/ProjectMonorail/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectMonorail/CollectionGenericObjects/MassiveGenericObjects.cs @@ -49,21 +49,21 @@ public class MassiveGenericObjects : ICollectionGenericObjects return i; } } - return 0; + return -1; } - public bool Insert(T obj, int position) + public int Insert(T obj, int position) { if (position < 0 || position >= Count) { - return false; + return -1; } for (int i = position; i < Count; i++) { if (_collection[i] == null) { _collection[i] = obj; - return true; + return i; } } for (int i = position - 1; i >= 0; i--) @@ -71,10 +71,10 @@ public class MassiveGenericObjects : ICollectionGenericObjects if (_collection[i] == null) { _collection[i] = obj; - return true; + return i; } } - return false; + return -1; } public T Remove(int position) diff --git a/ProjectMonorail/CollectionGenericObjects/TrainSharingService.cs b/ProjectMonorail/CollectionGenericObjects/TrainSharingService.cs index cf35e67..0153a3f 100644 --- a/ProjectMonorail/CollectionGenericObjects/TrainSharingService.cs +++ b/ProjectMonorail/CollectionGenericObjects/TrainSharingService.cs @@ -41,9 +41,9 @@ public class TrainSharingService : AbstractCompany { int counter = 0; int valPlaceY = _pictureHeight / _placeSizeHeight; - for (int y = (valPlaceY - 1) * _placeSizeHeight; y >= 0; y -= _placeSizeHeight) + for (int y = ((valPlaceY - 1) * _placeSizeHeight) + 30; y >= 0; y -= _placeSizeHeight) { - for (int x = 5; x + _placeSizeWidth < _pictureWidth; x += _placeSizeWidth) + for (int x = 10; x + _placeSizeWidth < _pictureWidth; x += _placeSizeWidth) { _collection?.Get(counter)?.SetPictureSize(_pictureWidth, _pictureHeight); _collection?.Get(counter)?.SetPosition(x, y); diff --git a/ProjectMonorail/FormTrainCollection.cs b/ProjectMonorail/FormTrainCollection.cs index 90f43d6..b46804d 100644 --- a/ProjectMonorail/FormTrainCollection.cs +++ b/ProjectMonorail/FormTrainCollection.cs @@ -86,7 +86,7 @@ public partial class FormTrainCollection : Form default: return; } - if (_company + drawingTrain != 0) + if (_company + drawingTrain != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show();