Done
This commit is contained in:
parent
e898da222c
commit
76bed1f328
@ -119,17 +119,17 @@ namespace Cruiser.Generics
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var bus in _collection.GetBuses())
|
||||
foreach (var cruiser in _collection.GetCruiser())
|
||||
{
|
||||
if (bus != null)
|
||||
if (cruiser != null)
|
||||
{
|
||||
int inRow = _pictureWidth / _placeSizeWidth;
|
||||
bus.SetPosition(_placeSizeWidth * (inRow - 1) - (i % inRow * _placeSizeWidth), i / inRow * _placeSizeHeight);
|
||||
bus.DrawTransport(g);
|
||||
cruiser.SetPosition(_placeSizeWidth * (inRow - 1) - (i % inRow * _placeSizeWidth), i / inRow * _placeSizeHeight);
|
||||
cruiser.DrawTransport(g);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
public IEnumerable<T?> GetCruisers => _collection.GetBuses();
|
||||
public IEnumerable<T?> GetCruisers => _collection.GetCruiser();
|
||||
}
|
||||
}
|
@ -70,7 +70,7 @@ namespace Cruiser.Generics
|
||||
}
|
||||
using (StreamWriter sw = new(filename))
|
||||
{
|
||||
sw.WriteLine($"PlaneStorage{Environment.NewLine}{data}");
|
||||
sw.WriteLine($"CruiserStorage{Environment.NewLine}{data}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -106,10 +106,10 @@ namespace Cruiser.Generics
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawningCruiser? plane = elem?.CreateDrawningCruiser(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (plane != null)
|
||||
DrawningCruiser? cruiser = elem?.CreateDrawningCruiser(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (cruiser != null)
|
||||
{
|
||||
if (!(collection + plane))
|
||||
if (!(collection + cruiser))
|
||||
{
|
||||
throw new ArgumentNullException("Ошибка добавления в коллекцию");
|
||||
}
|
||||
|
@ -24,20 +24,20 @@ namespace Cruiser.Generics
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
|
||||
public void Insert(T trolleybus)
|
||||
public void Insert(T cruiser)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
Insert(trolleybus, 0);
|
||||
Insert(cruiser, 0);
|
||||
}
|
||||
|
||||
public void Insert(T trolleybus, int position)
|
||||
public void Insert(T cruiser, int position)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
if (!(position >= 0 && position <= Count))
|
||||
throw new Exception("Неверная позиция для вставки");
|
||||
_places.Insert(position, trolleybus);
|
||||
_places.Insert(position, cruiser);
|
||||
}
|
||||
|
||||
public void Remove(int position)
|
||||
@ -62,12 +62,12 @@ namespace Cruiser.Generics
|
||||
_places.Insert(position, value);
|
||||
}
|
||||
}
|
||||
public IEnumerable<T?> GetBuses(int? maxBuses = null)
|
||||
public IEnumerable<T?> GetCruiser(int? maxCruisers = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxBuses.HasValue && i == maxBuses.Value)
|
||||
if (maxCruisers.HasValue && i == maxCruisers.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user