Добавление интерфейса.
This commit is contained in:
parent
45020f50ad
commit
486473543f
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
namespace Airbus
|
namespace Airbus
|
||||||
{
|
{
|
||||||
//класс, отвечающий за прорисовку и перемещение объект
|
//класс, отвечающий за прорисовку и перемещение объект
|
||||||
internal class DrawingAirbus
|
internal class DrawningAirbus
|
||||||
{
|
{
|
||||||
public EntityAirbus Airbus { get; protected set; } //класс-сущность
|
public EntityAirbus Airbus { get; protected set; } //класс-сущность
|
||||||
|
|
||||||
@ -24,11 +24,11 @@ namespace Airbus
|
|||||||
protected readonly int _airbusHeight = 62; //высота отрисовки самолёта
|
protected readonly int _airbusHeight = 62; //высота отрисовки самолёта
|
||||||
|
|
||||||
//инициализаци свойств
|
//инициализаци свойств
|
||||||
public DrawingAirbus(int speed, float weight, Color corpusColor)
|
public DrawningAirbus(int speed, float weight, Color corpusColor)
|
||||||
{
|
{
|
||||||
Airbus = new EntityAirbus(speed, weight, corpusColor);
|
Airbus = new EntityAirbus(speed, weight, corpusColor);
|
||||||
}
|
}
|
||||||
protected DrawingAirbus(int speed, float weight, Color corpusColor, int airbusWidth, int airbusHeight) :
|
protected DrawningAirbus(int speed, float weight, Color corpusColor, int airbusWidth, int airbusHeight) :
|
||||||
this(speed, weight, corpusColor)
|
this(speed, weight, corpusColor)
|
||||||
{
|
{
|
||||||
_airbusWidth = airbusWidth;
|
_airbusWidth = airbusWidth;
|
||||||
@ -196,5 +196,10 @@ namespace Airbus
|
|||||||
_startPosY = _pictureHeight.Value - _airbusHeight;
|
_startPosY = _pictureHeight.Value - _airbusHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//получение текущей позиции объекта
|
||||||
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return (_startPosX, _startPosY, _startPosX + _airbusWidth, _startPosY + _airbusHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
40
Airbus/Airbus/DrawningObjectAirbus.cs
Normal file
40
Airbus/Airbus/DrawningObjectAirbus.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Airbus
|
||||||
|
{
|
||||||
|
internal class DrawningObjectAirbus: IDrawningObject
|
||||||
|
{
|
||||||
|
private DrawningAirbus _airbus;
|
||||||
|
|
||||||
|
public float Step => _airbus?.Airbus?.Step ?? 0;
|
||||||
|
|
||||||
|
public DrawningObjectAirbus(DrawningAirbus airbus)
|
||||||
|
{
|
||||||
|
_airbus = airbus;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDrawningObject.DrawningObject(Graphics g)
|
||||||
|
{
|
||||||
|
//ДОДУМАТЬ ЛОГИКУ ЭТОГО МЕТОДА
|
||||||
|
}
|
||||||
|
|
||||||
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return _airbus?.GetCurrentPosition() ?? default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveObject(Direction direction)
|
||||||
|
{
|
||||||
|
_airbus?.MoveTransport(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetObject(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
_airbus?.SetPosition(x, y, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Airbus
|
namespace Airbus
|
||||||
{
|
{
|
||||||
internal class DrawingSuperAirbus : DrawingAirbus
|
internal class DrawningSuperAirbus : DrawningAirbus
|
||||||
{
|
{
|
||||||
//Инициализаци свойств
|
//Инициализаци свойств
|
||||||
public DrawingSuperAirbus(int speed, float weight, Color corpusColor, Color addColor, bool addCompartment, bool addEngine) :
|
public DrawningSuperAirbus(int speed, float weight, Color corpusColor, Color addColor, bool addCompartment, bool addEngine) :
|
||||||
base(speed, weight, corpusColor, 110, 60)
|
base(speed, weight, corpusColor, 110, 60)
|
||||||
{
|
{
|
||||||
Airbus = new EntitySuperAirbus(speed, weight, corpusColor, addColor, addCompartment, addEngine);
|
Airbus = new EntitySuperAirbus(speed, weight, corpusColor, addColor, addCompartment, addEngine);
|
@ -12,7 +12,7 @@ namespace Airbus
|
|||||||
{
|
{
|
||||||
public partial class FormAirbus : Form
|
public partial class FormAirbus : Form
|
||||||
{
|
{
|
||||||
private DrawingAirbus _airbus;
|
private DrawningAirbus _airbus;
|
||||||
public FormAirbus()
|
public FormAirbus()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -39,7 +39,7 @@ namespace Airbus
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_airbus = new DrawingAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000),Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
_airbus = new DrawningAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000),Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ namespace Airbus
|
|||||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_airbus = new DrawingSuperAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
_airbus = new DrawningSuperAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
|
27
Airbus/Airbus/IDrawningObject.cs
Normal file
27
Airbus/Airbus/IDrawningObject.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Airbus
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user