Конец четвертой лабы

This commit is contained in:
KirillFirsof 2023-11-10 08:32:07 +04:00
parent c06691432d
commit caaf1bf162
3 changed files with 10 additions and 15 deletions

View File

@ -81,7 +81,7 @@ namespace ProjectTractor.DrawningObjects {
}
/// <summary>
/// Получение объекта IMoveableObject из объекта DrawningCar
/// Получение объекта IMoveableObject из объекта DrawningTractor
/// </summary>
public IMoveableObject GetMoveableObject => new
DrawningObjectTractor(this);

View File

@ -37,20 +37,15 @@ namespace ProjectTractor.Generics
/// <returns></returns>
public bool Insert(T tractor)
{
if (_places[0] == null)
{
_places[0] = tractor;
}
else
{
return Insert(tractor, 0);
}
if (_places.Count == _maxCount)
return false;
Insert(tractor, 0);
return true;
}
/// <summary>
/// Добавление объекта в набор на конкретную позицию
/// </summary>
/// <param name="car">Добавляемый автомобиль</param>
/// <param name="tractor">Добавляемый автомобиль</param>
/// <param name="position">Позиция</param>
/// <returns></returns>
public bool Insert(T tractor, int position)
@ -96,7 +91,7 @@ namespace ProjectTractor.Generics
/// Проход по списку
/// </summary>
/// <returns></returns>
public IEnumerable<T?> GetCars(int? maxTractors = null)
public IEnumerable<T?> GetTractors(int? maxTractors = null)
{
for (int i = 0; i < _places.Count; ++i)
{

View File

@ -9,7 +9,7 @@ using ProjectTractor.MovementStrategy;
namespace ProjectTractor.Generics
{
/// <summary>
/// Параметризованный класс для набора объектов DrawningCar
/// Параметризованный класс для набора объектов DrawningTractor
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
@ -129,12 +129,12 @@ namespace ProjectTractor.Generics
private void DrawObjects(Graphics g)
{
int i = 0;
foreach (var tractor in _collection.GetCars())
foreach (var tractor in _collection.GetTractors())
{
if (tractor != null)
{
int inRow = _pictureWidth / _placeSizeWidth;
tractor.SetPosition(_pictureWidth - _placeSizeWidth - (i % inRow * _placeSizeWidth) - _placeSizeHeight / 2 - 8, i / inRow * _placeSizeHeight + 20);
int countRows = _pictureWidth / _placeSizeWidth;
tractor.SetPosition(_pictureWidth - _placeSizeWidth * 2 - (i % countRows * _placeSizeWidth) + 20, _pictureHeight - i / countRows * _placeSizeHeight - 160);
tractor.DrawTransport(g);
}
i++;