diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs index f8bd775..0a55ad4 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs @@ -76,7 +76,7 @@ public abstract class AbstractCompany public DrawningTrackedVehicle? GetRandomObject() { Random rnd = new(); - return _collection?.Get(rnd.Next(GetMaxCount)); + return arr?.Get(rnd.Next(GetMaxCount)); } /// @@ -85,14 +85,18 @@ public abstract class AbstractCompany /// public Bitmap? Show() { - Bitmap bitmap = new(_pictureWidth, _pictureHeight); + Bitmap bitmap = new(pictureWidth, pictureHeight); Graphics graphics = Graphics.FromImage(bitmap); DrawBackgound(graphics); SetObjectsPosition(); - for (int i = 0; i < (_collection?.Count ?? 0); ++i) + for (int i = 0; i < (arr?.Count ?? 0); ++i) { - DrawningTrackedVehicle? obj = _collection?.Get(i); - obj?.DrawTransport(graphics); + try + { + DrawningTrackedVehicle? obj = arr?.Get(i); + obj?.DrawTransport(graphics); + } + catch (Exception) { } } return bitmap; }