Проверенно
This commit is contained in:
parent
d29a47f44e
commit
3e7c3c7f5f
@ -55,7 +55,7 @@ namespace WarmlyShip
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectShip ship = new(form.SelectedShip);
|
||||
if (_mapShipCollectionGeneric + ship == 1)
|
||||
if (_mapShipCollectionGeneric + ship > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
@ -78,7 +78,7 @@ namespace WarmlyShip
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapShipCollectionGeneric - pos == 1)
|
||||
if (_mapShipCollectionGeneric - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
|
@ -32,7 +32,7 @@ namespace WarmlyShip
|
||||
return map._setShips.Insert(ship);
|
||||
}
|
||||
|
||||
public static int operator -(MapWithSetShipGeneric<T, U> map, int position)
|
||||
public static T operator -(MapWithSetShipGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setShips.Remove(position);
|
||||
}
|
||||
|
@ -26,25 +26,12 @@ namespace WarmlyShip
|
||||
|
||||
public int Insert(T ship)
|
||||
{
|
||||
if (CanInsert(0))
|
||||
{
|
||||
for (int i = _places.Length - 1; i > 0; --i)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
_places[i - 1] = null;
|
||||
}
|
||||
}
|
||||
_places[0] = ship;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return Insert(ship, 0);
|
||||
}
|
||||
|
||||
public int Insert(T ship, int position)
|
||||
{
|
||||
if (position < 0 || position > _places.Length) return 0;
|
||||
if (position < 0 || position > _places.Length) return -1;
|
||||
if (_places[position] != null && CanInsert(position))
|
||||
{
|
||||
for (int i = _places.Length - 1; i > position; --i)
|
||||
@ -57,13 +44,14 @@ namespace WarmlyShip
|
||||
}
|
||||
}
|
||||
_places[position] = ship;
|
||||
return 1;
|
||||
return position;
|
||||
}
|
||||
|
||||
public int Remove(int position)
|
||||
public T Remove(int position)
|
||||
{
|
||||
T DelElement = _places[position];
|
||||
_places[position] = null;
|
||||
return 1;
|
||||
return DelElement;
|
||||
}
|
||||
|
||||
public T Get(int position)
|
||||
|
Loading…
Reference in New Issue
Block a user