PIbd-22 Chubykina P.P. LabWork_04 #4
@ -62,7 +62,7 @@ namespace Sailboat.Generics
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return collect?._collection.Insert(obj) ?? false;
|
||||
return (bool)collect?._collection.Insert(obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
@ -70,14 +70,14 @@ namespace Sailboat.Generics
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static T? operator -(BoatsGenericCollection<T, U> collect, int pos)
|
||||
public static bool operator -(BoatsGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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++;
|
||||
|
@ -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),
|
||||
|
@ -36,8 +36,10 @@ namespace Sailboat.Generics
|
||||
/// <returns></returns>
|
||||
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
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user