Изменен тип возвращаемого значения в перегрузке оператора вычитания

This commit is contained in:
Валерия Никифорова 2022-10-13 22:02:44 +04:00
parent 0d114ff27d
commit 475ac61fa7

View File

@ -60,7 +60,7 @@ namespace AccordionBus
/// </summary>
/// <param name="map"></param>
/// <param name="bus"></param>
/// <returns></returns>
/// <returns>Возвращает позицию вставленого объекта либо -1, если не получилось его добавить</returns>
public static int operator +(MapWithSetBusesGeneric<T, U> map, T bus)
{
return map._setBuses.Insert(bus);
@ -70,8 +70,8 @@ namespace AccordionBus
/// </summary>
/// <param name="map"></param>
/// <param name="position"></param>
/// <returns></returns>
public static int operator -(MapWithSetBusesGeneric<T, U> map, int position)
/// <returns>Возвращает удаленный объект, либо null если его не удалось удалить</returns>
public static T operator -(MapWithSetBusesGeneric<T, U> map, int position)
{
return map._setBuses.Remove(position);
}
@ -94,13 +94,9 @@ namespace AccordionBus
public Bitmap ShowOnMap()
{
Shaking();
for (int i = 0; i < _setBuses.Count; i++)
foreach (var bus in _setBuses.GetBuses())
{
var bus = _setBuses.Get(i);
if (bus != null)
{
return _map.CreateMap(_pictureWidth, _pictureHeight, bus);
}
return _map.CreateMap(_pictureWidth, _pictureHeight, bus);
}
return new(_pictureWidth, _pictureHeight);
}
@ -125,11 +121,11 @@ namespace AccordionBus
int j = _setBuses.Count - 1;
for (int i = 0; i < _setBuses.Count; i++)
{
if (_setBuses.Get(i) == null)
if (_setBuses[i] == null)
{
for (; j > i; j--)
{
var bus = _setBuses.Get(j);
var bus = _setBuses[j];
if (bus != null)
{
_setBuses.Insert(bus, i);
@ -172,10 +168,12 @@ namespace AccordionBus
int numberOfSeatsInHeight = _pictureHeight / _placeSizeHeight;
int rightLine = (numberOfSeatsInWidth - 1) * _placeSizeWidth;
int bottomLine = (numberOfSeatsInHeight - 1) * _placeSizeHeight;
for (int i = 0; i < _setBuses.Count; i++)
int count = 0;
foreach (var bus in _setBuses.GetBuses())
{
_setBuses.Get(i)?.SetObject(rightLine - i % numberOfSeatsInWidth * _placeSizeWidth, bottomLine - i / numberOfSeatsInWidth * _placeSizeHeight, _pictureWidth, _pictureHeight);
_setBuses.Get(i)?.DrawningObject(g);
bus.SetObject(rightLine - count % numberOfSeatsInWidth * _placeSizeWidth, bottomLine - count / numberOfSeatsInWidth * _placeSizeHeight, _pictureWidth, _pictureHeight);
bus.DrawningObject(g);
count++;
}
}
}