Добавление интерфейса.

This commit is contained in:
Макс Бондаренко 2022-10-04 21:57:28 +04:00
parent e51d851a32
commit 4356388162
3 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WarmlyShip
{
internal class DrawningObjectShip : IDrawningObject
{
private DrawningWarmlyShip _warmlyShip = null;
public DrawningObjectShip(DrawningWarmlyShip warmlyShip)
{
_warmlyShip = warmlyShip;
}
public float Step => _warmlyShip?.warmlyShip?.Step ?? 0;
public void DrawningObject(Graphics g)
{
_warmlyShip?.DrawTransport(g);
}
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return _warmlyShip?.GetCurrentPosition() ?? default;
}
public void MoveObject(Direction direction)
{
_warmlyShip?.MoveTransport(direction);
}
public void SetObject(int x, int y, int width, int height)
{
_warmlyShip?.SetPosition(x, y, width, height);
}
}
}

View File

@ -114,5 +114,10 @@ namespace WarmlyShip
}
}
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosY, _startPosX + _warmlyShipWidth, _startPosY + _warmlyShipHeight);
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WarmlyShip
{
internal interface IDrawningObject
{
public float Step { get; }
void SetObject(int x, int y, int width, int height);
void MoveObject(Direction direction);
void DrawningObject(Graphics g);
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
}
}