Aleikin A.M. LabWork03 #3

Merged
eegov merged 4 commits from LabWork03 into LabWork02 2022-11-07 12:37:17 +04:00
3 changed files with 11 additions and 10 deletions
Showing only changes of commit 5181a68461 - Show all commits

View File

@ -29,7 +29,7 @@ namespace AirBomber
if (form.ShowDialog() == DialogResult.OK)
{
DrawningObjectBomber airBomber = new(form.SelectedAirBomber);
if (_mapAirBomberCollectionGeneric + airBomber == 1)
if (_mapAirBomberCollectionGeneric + airBomber > -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapAirBomberCollectionGeneric.ShowSet();
@ -52,7 +52,7 @@ namespace AirBomber
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapAirBomberCollectionGeneric - pos == 1)
if (_mapAirBomberCollectionGeneric - pos != null)
{
MessageBox.Show("Объект удален");
pictureBox.Image = _mapAirBomberCollectionGeneric.ShowSet();

View File

@ -32,7 +32,7 @@ namespace AirBomber
return map._setAirBomber.Insert(airBomber);
}
public static int operator -(MapWithSetAirBomberGeneric<T, U> map, int position)
public static T operator -(MapWithSetAirBomberGeneric<T, U> map, int position)
{
return map._setAirBomber.Remove(position);
}

View File

@ -27,13 +27,13 @@ namespace AirBomber
{
if (position < 0 || position >= Count)
{
return 0;
return -1;
}
int emptyPos = -1;
if (_places[position] == null)
{
_places[position] = airBomber;
return 1;
return position;
}
else
{
@ -56,22 +56,23 @@ namespace AirBomber
if (emptyPos != -1)
{
_places[position] = airBomber;
return 1;
return position;
}
else
{
return 0;
return -1;
}
}
public int Remove(int position)
public T Remove(int position)
{
if (position < 0 || position >= Count)
{
return 0;
return null;
}
T elem = _places[position];
_places[position] = null;
return 1;
return elem;
}
public T Get(int position)