готовая лаба 4

This commit is contained in:
1SooNoo1 2023-11-04 13:43:40 +04:00
parent bccce47300
commit 00d54fe26c
3 changed files with 8 additions and 8 deletions

View File

@ -26,13 +26,13 @@ namespace ProjectExcavator.Generic
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
public static bool operator +(ExcavatorGenericCollection<T, U> collect, T? obj)
public static int operator +(ExcavatorGenericCollection<T, U> collect, T? obj)
{
if (obj == null)
{
return false;
return -1;
}
return collect?._collection.Insert(obj) ?? false;
return collect?._collection.Insert(obj) ?? -1;
}
public static T? operator -(ExcavatorGenericCollection<T, U> collect, int pos)
{

View File

@ -97,10 +97,10 @@ pictureBoxCollection.Height);
{
return;
}
ExcavatorForm form = new();
ExcavatorForm form = new ExcavatorForm();
if (form.ShowDialog() == DialogResult.OK)
{
if (obj + form.SelectedExcavator)
if ((obj + form.SelectedExcavator) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowExcavator();

View File

@ -17,14 +17,14 @@ namespace ProjectExcavator.Generic
_maxCount = count;
_places = new List<T>(_maxCount);
}
public bool Insert(T excavator)
public int Insert(T excavator)
{
if(_places.Count >= _maxCount)
{
return false;
return -1;
}
_places.Insert(0, excavator);
return true;
return 0;
}
public bool Insert(T excavator, int position)
{