PIbd-21_Rasubaev S.M._Lab5 #5

Closed
Sergey wants to merge 2 commits from lab_5 into lab_4
3 changed files with 13 additions and 11 deletions
Showing only changes of commit 0db70e3020 - Show all commits

View File

@ -81,18 +81,18 @@ namespace HoistingCrane.Generics
int k = _pictureHeight/_placeSizeHeight-1;
foreach (var crane in _collection.GetCranes())
{
if (crane != null)
if (j < 0)
{
j += _pictureWidth / _placeSizeWidth;
k--;
}
obj = crane;
if (obj != null)
{
if (j < 0)
{
j += _pictureWidth / _placeSizeWidth;
k--;
}
obj = crane;
obj.SetPosition(_placeSizeWidth * j, _placeSizeHeight * k);
obj.DrawTransport(g);
j--;
}
j--;
}
}
}

View File

@ -72,7 +72,7 @@ namespace HoistingCrane
var obj = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty];
if (obj != null)
{
if (obj + crane != 1)
if (obj + crane != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowCars();

View File

@ -20,6 +20,8 @@
/// Добавление объекта в набор
public int Insert(T crane)
{
if(crane==null)
return -1;
_places.Insert(0, crane);
return 0;
}
@ -33,8 +35,8 @@
/// Удаление объекта из набора с конкретной позиции
public bool Remove(int position)
{
if ((position < 0) || (position > _maxCount)) return false;
_places.RemoveAt(position);
if ((position < 0) || (position > _maxCount)|| (_places[position] == null)) return false;
_places[position] = null;
return true;
}
/// Получение объекта из набора по позиции