Compare commits

..

No commits in common. "10edf8895bab1a754a4b4c928aa00aaebad0a208" and "f89e86bd93dff6ad9d939764227284bd843d5973" have entirely different histories.

3 changed files with 22 additions and 29 deletions

View File

@ -106,7 +106,7 @@ namespace AntiAircraftGun
FormAntiAirCraftGun form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if ((obj + form.SelectedZenit)==1)
if (obj + form.SelectedZenit)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowZenits();

View File

@ -51,26 +51,31 @@ namespace AntiAircraftGun.Generics
/// <param name="collect"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static int operator +(AntiAirCraftGunGenericCollection<T,U> collect, T? obj)
public static bool operator +(AntiAirCraftGunGenericCollection<T, U> collect, T? obj)
{
if (obj == null)
return -1;
return collect?._collection.Insert(obj) ?? -1;
{
MessageBox.Show("Объект пустой. Невозможно добавить.");
return false;
}
return collect?._collection.Insert(obj) ?? false;
}
/// <summary>
/// Перегрузка оператора вычитания
/// </summary>
/// <param name="collect"></param>
/// <param name="pos"></param>
/// <returns></returns>
public static bool operator -(AntiAirCraftGunGenericCollection<T, U> collect, int pos)
public static T? operator -(AntiAirCraftGunGenericCollection<T, U> collect, int pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
return collect._collection.Remove(pos);
return false;
T? obj = collect._collection[pos];
if (obj != null)
{
collect._collection.Remove(pos);
}
return obj;
}
/// <summary>
/// Получение объекта IMoveableObject
/// </summary>
@ -151,21 +156,9 @@ namespace AntiAircraftGun.Generics
if (y + distance_between_objects >= maxY)
{
y = 0;
x += _placeSizeWidth;
x += obj.GetWidth + 10 + _placeSizeWidth;
}
}
if (obj == null)
{
// Увеличиваем координату Y для следующего объекта
y += distance_between_objects;
// Проверяем, если Y достигло максимума, изменяем X и сбрасываем Y
if (y+distance_between_objects >= maxY)
{
y = 0;
x += _placeSizeWidth;
}
};
}
}
}

View File

@ -35,21 +35,21 @@ namespace AntiAircraftGun.Generics
/// </summary>
/// <param name="car">Добавляемый автомобиль</param>
/// <returns></returns>
public int Insert(T car)
public bool Insert(T car)
{
if (_places.Count == _maxCount)
return -1;
return false;
Insert(car, 0);
return 1;
return true;
}
public int Insert(T car, int position)
public bool Insert(T car, int position)
{
if (!(position >= 0 && position <= Count && _places.Count < _maxCount))
return -1;
return false;
_places.Insert(position, car);
return 1;
return true;
}
/// <summary>