снова

This commit is contained in:
Timourka 2023-10-23 23:51:58 +04:00
parent a1f0b7d534
commit 986512d2fc
2 changed files with 8 additions and 8 deletions

View File

@ -113,12 +113,12 @@ namespace Laba1Loco
/// Проход по списку
/// </summary>
/// <returns></returns>
public IEnumerable<T> GetTrains(int? maxCars = null)
public IEnumerable<T> GetTrains(int? maxTrains = null)
{
for (int i = 0; i < _places.Count; ++i)
{
yield return _places[i];
if (maxCars.HasValue && i == maxCars.Value)
if (maxTrains.HasValue && i == maxTrains.Value)
{
yield break;
}

View File

@ -120,15 +120,15 @@ where U : IMoveableObject
private void DrawObjects(Graphics g)
{
int i = 0;
foreach (var car in _collection.GetTrains())
foreach (var train in _collection.GetTrains())
{
if (car != null)
if (train != null)
{
car.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
if (car is DrawingLoco)
(car as DrawingLoco).DrawTransport(g);
train.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
if (train is DrawingLoco)
(train as DrawingLoco).DrawTransport(g);
else
car.DrawTransport(g);
train.DrawTransport(g);
}
i++;
}