diff --git a/ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs b/ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs index 036d62c..e4a7e64 100644 --- a/ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs +++ b/ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs @@ -176,8 +176,8 @@ namespace ArmoredCar int k = 0; foreach (var armoredCar in _setCars.GetCars()) { - armoredCar?.SetObject(k % width * _placeSizeWidth + 5, k / width * _placeSizeHeight + 10, _pictureWidth, _pictureHeight); - armoredCar?.DrawningObject(g); + armoredCar.SetObject(k % width * _placeSizeWidth + 5, k / width * _placeSizeHeight + 10, _pictureWidth, _pictureHeight); + armoredCar.DrawningObject(g); k++; } } @@ -191,10 +191,7 @@ namespace ArmoredCar string data = $"{_map.GetType().Name}{separatorType}"; foreach (var armoredCar in _setCars.GetCars()) { - if (armoredCar != null) - data += $"{armoredCar.GetInfo()}{separatorData}"; - else - data += $"null{separatorData}"; + data += $"{armoredCar.GetInfo()}{separatorData}"; } return data; } @@ -206,10 +203,7 @@ namespace ArmoredCar { foreach (var rec in records) { - if (rec != "null") - _setCars.Insert(DrawningObjectArmCar.Create(rec) as T); - else - _setCars.Insert(null); + _setCars.Insert(DrawningObjectArmCar.Create(rec) as T); } } } diff --git a/ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs b/ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs index fabb0b3..6d63325 100644 --- a/ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs +++ b/ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs @@ -65,7 +65,7 @@ namespace ArmoredCar T armoredCar = _places[position]; if (armoredCar == null) throw new ArmoredCarNotFoundException(position); - _places[position] = null; + _places.RemoveAt(position); return armoredCar; } /// @@ -98,15 +98,14 @@ namespace ArmoredCar { foreach (var car in _places) { - yield return car; - /*if (car != null) + if (car != null) { yield return car; } else { yield break; - }*/ + } } }