Добавление интерфейса.
This commit is contained in:
parent
c4a88ba804
commit
98ffecd556
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Airbus
|
||||
{
|
||||
//класс, отвечающий за прорисовку и перемещение объекта
|
||||
internal class DrawingAirbus
|
||||
internal class DrawningAirbus
|
||||
{
|
||||
public EntityAirbus Airbus { get; protected set; } //класс-сущность
|
||||
|
||||
@ -24,12 +24,12 @@ namespace Airbus
|
||||
protected readonly int _airbusHeight = 16; //высота отрисовки самолёта
|
||||
|
||||
//инициализаци свойств
|
||||
public DrawingAirbus(int speed, float weight, Color corpusColor)
|
||||
public DrawningAirbus(int speed, float weight, Color 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)
|
||||
{
|
||||
_airbusWidth = airbusWidth;
|
||||
@ -156,5 +156,11 @@ namespace Airbus
|
||||
_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
|
||||
{
|
||||
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)
|
||||
{
|
||||
Airbus = new EntitySuperAirbus(speed, weight, corpusColor, addColor, addCompartment, addEngine);
|
@ -12,7 +12,7 @@ namespace Airbus
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private DrawingAirbus _airbus;
|
||||
private DrawningAirbus _airbus;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
@ -42,7 +42,7 @@ namespace Airbus
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_airbus = new DrawingAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
_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();
|
||||
Draw();
|
||||
@ -81,7 +81,7 @@ namespace Airbus
|
||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
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)),
|
||||
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 Microsoft.VisualBasic.Logging;
|
||||
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