ISBd_21.GordeevI.V._LabWork_07 #11

Closed
Igor_Gordeev wants to merge 7 commits from ISBd_21.GordeevI.V._LabWork_07 into ISBd_21.GordeevI.V._LabWork_06
2 changed files with 8 additions and 10 deletions
Showing only changes of commit 9b337df21c - Show all commits

View File

@ -145,8 +145,7 @@ namespace ElectricLocomotive
int pos = Convert.ToInt32(Input.Text);
try
{
var removeObj = obj - pos;
if (removeObj != null)
if ( obj - pos != null )
{
MessageBox.Show("Объект удален");
_logger.LogInformation($"Удален объект с позиции{pos}");
@ -155,6 +154,7 @@ namespace ElectricLocomotive
else
{
MessageBox.Show("Не удалось удалить объект");
_logger.LogWarning($"Не удалось удалить объект из набора {listBoxStorage.SelectedItem.ToString()}");
}
}
catch (LocoNotFoundException ex)

View File

@ -36,16 +36,14 @@ namespace ProjectElectricLocomotive.Generics
_places.Insert(position, loco);
return position;
}
public T? Remove(int position)
public bool Remove(int position)
{
if (position >= Count || position < 0)
return null;
T? tmp = _places[position];
if (tmp == null)
if (position < 0 || position >= _places.Count)
{
throw new LocoNotFoundException(position);
_places[position] = null;
return tmp;
}
_places.RemoveAt(position);
return true;
}
public T? this[int position]
{