diff --git a/Sailboat/Sailboat/BoatsGenericCollection.cs b/Sailboat/Sailboat/BoatsGenericCollection.cs index 160b983..f127575 100644 --- a/Sailboat/Sailboat/BoatsGenericCollection.cs +++ b/Sailboat/Sailboat/BoatsGenericCollection.cs @@ -62,7 +62,7 @@ namespace Sailboat.Generics { return false; } - return collect?._collection.Insert(obj) ?? false; + return (bool)collect?._collection.Insert(obj); } /// /// Перегрузка оператора вычитания @@ -70,14 +70,14 @@ namespace Sailboat.Generics /// /// /// - public static T? operator -(BoatsGenericCollection collect, int pos) + public static bool operator -(BoatsGenericCollection collect, int pos) { T? obj = collect._collection[pos]; if (obj != null) { collect._collection.Remove(pos); } - return obj; + return false; } /// @@ -133,7 +133,7 @@ namespace Sailboat.Generics if (boat != null) { int width = _pictureWidth / _placeSizeWidth; - boat.SetPosition(i % width * _placeSizeWidth, _pictureHeight - _pictureHeight % _placeSizeHeight - (i / width + 1) * _placeSizeHeight); + boat.SetPosition(i % width * _placeSizeWidth, i / width * _placeSizeHeight); boat.DrawTransport(g); } i++; diff --git a/Sailboat/Sailboat/FormSailboat.cs b/Sailboat/Sailboat/FormSailboat.cs index edbfb8a..bd6e458 100644 --- a/Sailboat/Sailboat/FormSailboat.cs +++ b/Sailboat/Sailboat/FormSailboat.cs @@ -52,10 +52,9 @@ namespace Sailboat Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); - ColorDialog dialogAddColor = new(); - if (dialogAddColor.ShowDialog() == DialogResult.OK) + if (dialog.ShowDialog() == DialogResult.OK) { - dopColor = dialogAddColor.Color; + dopColor = dialog.Color; } _drawingBoat = new DrawingSailboat(random.Next(100, 300), diff --git a/Sailboat/Sailboat/SetGeneric.cs b/Sailboat/Sailboat/SetGeneric.cs index 95a2392..c5bd178 100644 --- a/Sailboat/Sailboat/SetGeneric.cs +++ b/Sailboat/Sailboat/SetGeneric.cs @@ -36,8 +36,10 @@ namespace Sailboat.Generics /// public bool Insert(T boat) { - if (_places.Count == _maxCount) - return false; + if (_places.Count == _maxCount) + { + return false; + } Insert(boat, 0); return true; } @@ -49,8 +51,9 @@ namespace Sailboat.Generics /// public bool Insert(T boat, int position) { - if (!(position >= 0 && position <= Count && _places.Count < _maxCount)) - return false; + if (!(position >= 0 && position <= Count && _places.Count < _maxCount)) { + return false; + } _places.Insert(position, boat); return true; } @@ -77,14 +80,16 @@ namespace Sailboat.Generics { get { - if (!(position >= 0 && position < Count)) - return null; + if (position < 0 || position >= Count) { + return null; + } return _places[position]; } set { - if (!(position >= 0 && position < Count && _places.Count < _maxCount)) - return; + if (!(position >= 0 && position < Count && _places.Count < _maxCount)) { + return; + } _places.Insert(position, value); return; }