PIbd-23 Yakobchuk S.V. LabWork_02 #2

Closed
sofia7ya wants to merge 13 commits from LabWork_02 into LabWork_01
Showing only changes of commit a52c951843 - Show all commits

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sailboat.DrawingObjects;
namespace Sailboat.MovementStrategy
{
/// <summary>
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningBoat (паттерн Adapter)
/// </summary>
public class DrawingObjectBoat : IMoveableObject
{
private readonly DrawingBoat? _drawingBoat = null;
public DrawingObjectBoat(DrawingBoat drawingBoat)
{
_drawingBoat = drawingBoat;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawingBoat == null || _drawingBoat.EntityBoat ==
null)
{
return null;
}
return new ObjectParameters(_drawingBoat.GetPosX, _drawingBoat.GetPosY, _drawingBoat.GetWidth, _drawingBoat.GetHeight);
}
}
public int GetStep => (int)(_drawingBoat?.EntityBoat?.Step ?? 0);
public bool CheckCanMove(DirectionType direction) =>
_drawingBoat?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) =>
_drawingBoat?.MoveTransport(direction);
}
}