Изменение возвращаемого значения для Insert

This commit is contained in:
Володя 2022-10-10 09:24:07 +03:00
parent cceb17014c
commit d9c71375fa
2 changed files with 10 additions and 9 deletions

View File

@ -119,7 +119,7 @@ namespace AirPlaneWithRadar
int CountWidth = _pictureWidth / _placeSizeWidth; int CountWidth = _pictureWidth / _placeSizeWidth;
int x = _pictureWidth - _placeSizeWidth - _placeSizeWidth/2 - _placeSizeWidth / 4; int x = _pictureWidth - _placeSizeWidth - _placeSizeWidth/2 - _placeSizeWidth / 4;
int y = (_pictureHeight - _placeSizeHeight)- _placeSizeHeight/2; int y = _placeSizeHeight/4;
for (int k = 0; k < _setPlains.Count; k++) for (int k = 0; k < _setPlains.Count; k++)
{ {
@ -137,7 +137,7 @@ namespace AirPlaneWithRadar
_setPlains.Get(k)?.SetObject(x, y, _pictureWidth, _pictureHeight); _setPlains.Get(k)?.SetObject(x, y, _pictureWidth, _pictureHeight);
_setPlains.Get(k)?.DrawningObject(g); _setPlains.Get(k)?.DrawningObject(g);
x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4; x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4;
y -= _placeSizeHeight ; y += _placeSizeHeight ;
} }
} }
@ -148,7 +148,7 @@ namespace AirPlaneWithRadar
else else
{ {
x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4; x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4;
y -= _placeSizeHeight; y += _placeSizeHeight;
} }
} }
} }

View File

@ -6,8 +6,9 @@ using System.Threading.Tasks;
namespace AirPlaneWithRadar namespace AirPlaneWithRadar
{ {
internal class SetPlaneGeneric<T> internal class SetPlaneGeneric<T,U>
where T : class where T : class
{ {
private readonly T[] _places; private readonly T[] _places;
public int Count => _places.Length; public int Count => _places.Length;
@ -33,14 +34,14 @@ namespace AirPlaneWithRadar
return -1; return -1;
} }
public bool Insert(T plain, int position) public int Insert(T plain, int position)
{ {
if (position > Count || position < 0) if (position > Count || position < 0)
return false; return -1;
if (_places[position] == null) if (_places[position] == null)
{ {
_places[position] = plain; _places[position] = plain;
return true; return position;
} }
else else
{ {
@ -53,11 +54,11 @@ namespace AirPlaneWithRadar
_places[j] = _places[j - 1]; _places[j] = _places[j - 1];
} }
_places[position] = plain; _places[position] = plain;
return true; return position;
} }
} }
} }
return false; return -1;
} }
public T Remove(int position) public T Remove(int position)