Compare commits

..

26 Commits
main ... Lab3

Author SHA1 Message Date
8aa5bce7ba for pull request 2023-12-13 15:49:33 +04:00
d2624a12bb Всё сделано для усложненки вроде 2023-12-10 20:22:26 +04:00
294c75c51c Что-то сделано в форме AdditionalGeneric, но не доделано 2023-12-10 18:12:21 +04:00
00b1a7182c Сделан параметризованный класс 2023-12-10 16:18:45 +04:00
0f18368d7f Перенесена вся базовая лаба, добавлены двигатели в отрисовку 2023-12-10 14:52:55 +04:00
69a0414756 Прописана логика формы-коллекции 2023-12-10 14:44:55 +04:00
e08aabd3df Изменение Program 2023-12-10 14:39:42 +04:00
8188c6e0cb Создана форма FormPlaneCollection, дополнена FormAirBomber (пока без двигателей) 2023-12-10 14:35:13 +04:00
18bee6af64 Дополнение класса DrawningAirPlane 2023-12-10 13:57:10 +04:00
618d9a5ae7 Создание PlanesGenericCollection 2023-12-10 13:55:42 +04:00
15200db2d1 Начало Lab3. Создание SetGeneric 2023-12-10 13:50:55 +04:00
c3bb9c66cc Всё сделано, Lab2 сдана 2023-11-29 21:08:42 +04:00
ec08a44682 Всё сделано в усложненной лабе 2023-11-26 22:01:52 +04:00
52dd126a68 Создан интерфейс для прорисовки IDrawningEngines 2023-11-26 17:20:02 +04:00
00d9cfc7d1 Полностью перенесена базовая лаба 2023-11-26 17:03:12 +04:00
64b0091916 Создание классов, дополнения классов (как во второй базовой) 2023-11-26 16:39:03 +04:00
dd3c707953 Обновленный класс прорисовки «продвинутого» объекта + fix in EntityAirBomber 2023-11-26 16:04:12 +04:00
127a35dea6 Обновленный класс-сущность «продвинутого» объекта 2023-11-26 15:49:30 +04:00
610206aade Создание DrawningAirPlane 2023-11-26 15:45:04 +04:00
bfcdcb08c6 Начало Lab2. Создание класса базовой сущности EntityAirPlane 2023-11-26 15:11:56 +04:00
72e1051113 Lab1: правки в генерации случайного кол-ва двигателей 2023-11-26 13:06:12 +04:00
08e1a6549e Правки Lab1: удаление закоменченного кода и ненужной "pen" 2023-11-26 12:52:04 +04:00
1e36d10d47 Всё выполнено в Lab1 2023-11-25 23:11:41 +04:00
829c70eb5b Создание класса DrawningAirBomber (пока без усложненных двигателей) 2023-11-25 17:54:56 +04:00
9e08b356b5 Создание класса DirectionType 2023-11-25 17:47:09 +04:00
97a19d085b Создание класса-сущности EntityAirBomber 2023-11-25 17:45:38 +04:00
40 changed files with 2184 additions and 51 deletions

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public abstract class AbstractStrategy
{
private IMoveableObject? _moveableObject;
private Status _state = Status.NotInit;
protected int FieldWidth { get; private set; }
protected int FieldHeight { get; private set; }
public Status GetStatus() { return _state; }
public void SetData(IMoveableObject moveableObject, int width, int height)
{
if (moveableObject == null)
{
_state = Status.NotInit;
return;
}
_state = Status.InProgress;
_moveableObject = moveableObject;
FieldWidth = width;
FieldHeight = height;
}
public void MakeStep()
{
if (_state != Status.InProgress)
{
return;
}
if (IsTargetDestinaion())
{
_state = Status.Finish;
return;
}
MoveToTarget();
}
protected bool MoveLeft() => MoveTo(DirectionType.Left);
protected bool MoveRight() => MoveTo(DirectionType.Right);
protected bool MoveUp() => MoveTo(DirectionType.Up);
protected bool MoveDown() => MoveTo(DirectionType.Down);
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
protected int? GetStep()
{
if (_state != Status.InProgress)
{
return null;
}
return _moveableObject?.GetStep;
}
protected abstract void MoveToTarget();
protected abstract bool IsTargetDestinaion();
private bool MoveTo(DirectionType directionType)
{
if (_state != Status.InProgress)
{
return false;
}
if (_moveableObject?.CheckCanMove(directionType) ?? false)
{
_moveableObject.MoveObject(directionType);
return true;
}
return false;
}
}
}

View File

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class AdditionalGeneric<T, U>
where T : EntityAirPlane
where U : IDrawningEngines
{
private T[] planes;
private U[] engines;
private int planesCount = 0;
private int enginesCount = 0;
private int _pictureWidth;
private int _pictureHeight;
private Random random;
public AdditionalGeneric(int count, int width, int height)
{
planes = new T[count];
engines = new U[count];
_pictureWidth = width;
_pictureHeight = height;
random = new Random();
}
public bool Add(T plane)
{
for (int i = 0; i < planes.Length; i++)
{
if (planes[i] == null)
{
planes[i] = plane;
planesCount++;
return true;
}
}
return false;
}
public bool Add(U engine)
{
for (int i = 0; i < planes.Length; i++)
{
if (engines[i] == null)
{
engines[i] = engine;
enginesCount++;
return true;
}
}
return false;
}
public DrawningAirPlane CreateDrawObject()
{
Random rand = new Random();
EntityAirPlane plane = planes[rand.Next(0, planesCount)];
IDrawningEngines engine = engines[rand.Next(0, enginesCount)];
if (plane is EntityAirBomber airBomber)
{
return new DrawningAirBomber(
plane.Speed,
plane.Weight,
plane.BodyColor,
airBomber.AdditionalColor,
airBomber.Bombs,
airBomber.FuelTanks,
_pictureWidth,
_pictureHeight,
engine.GetAmount(),
engine.GetShape()
);
}
return new DrawningAirPlane(
plane.Speed,
plane.Weight,
plane.BodyColor,
_pictureWidth,
_pictureHeight,
engine.GetAmount(),
engine.GetShape()
);
}
}
}

View File

@ -8,4 +8,19 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public enum DirectionType
{
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class DrawningAirBomber : DrawningAirPlane
{
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int width, int height, int engines, int enginesShape) :
base(speed, weight, bodyColor, width, height, engines, enginesShape)
{
if (EntityAirPlane != null)
{
EntityAirPlane = new EntityAirBomber(speed, weight, bodyColor, additionalColor, bombs, fuelTanks);
}
}
public override void DrawPlane(Graphics g)
{
if (EntityAirPlane is not EntityAirBomber airBomber)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
base.DrawPlane(g);
// bombs
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15);
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15);
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 30, 15, 15);
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 30, 15, 15);
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 70, 15, 15);
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 70, 15, 15);
// fueltanks
g.FillRectangle(additionalBrush, _startPosX + 85, _startPosY + 34, 30, 15);
g.DrawRectangle(pen, _startPosX + 85, _startPosY + 34, 30, 15);
g.FillRectangle(additionalBrush, _startPosX + 85, _startPosY + 70, 30, 15);
g.DrawRectangle(pen, _startPosX + 85, _startPosY + 70, 30, 15);
}
}
}

View File

@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class DrawningAirPlane
{
public EntityAirPlane? EntityAirPlane { get; protected set; }
private int _pictureWidth;
private int _pictureHeight;
protected int _startPosX;
protected int _startPosY;
protected readonly int _airPlaneWidth = 150;
protected readonly int _airPlaneHeight = 118;
private IDrawningEngines drawningEngines;
public DrawningAirPlane(int speed, double weight, Color bodyColor, int width, int height, int engines, int enginesShape)
{
if (width < _airPlaneWidth || height < _airPlaneHeight)
{
return;
}
_pictureWidth = width;
_pictureHeight = height;
EntityAirPlane = new EntityAirPlane(speed, weight, bodyColor);
switch (enginesShape)
{
case 1:
drawningEngines = new DrawningEnginesCircle();
break;
case 2:
drawningEngines = new DrawningEnginesTriangle();
break;
default:
drawningEngines = new DrawningEnginesRectangle();
break;
}
drawningEngines.SetAmount(engines);
}
public void SetPosition(int x, int y)
{
if (x < 0 || x + _airPlaneWidth > _pictureWidth)
{
x = _pictureWidth - _airPlaneWidth;
}
if (y < 0 || y + _airPlaneHeight > _pictureHeight)
{
y = _pictureHeight - _airPlaneHeight;
}
_startPosX = x;
_startPosY = y;
}
public virtual void DrawPlane(Graphics g)
{
if (EntityAirPlane == null)
{
return;
}
Pen pen = new(Color.Black);
Brush bodyColor = new SolidBrush(EntityAirPlane.BodyColor);
Brush wingsColor = new SolidBrush(Color.DeepPink);
g.FillPolygon(bodyColor, new Point[] //nose
{
new Point(_startPosX + 19, _startPosY + 50),
new Point(_startPosX + 19, _startPosY + 69),
new Point(_startPosX + 1, _startPosY + 59),
}
);
g.FillRectangle(bodyColor, _startPosX + 20, _startPosY + 50, 120, 20); //body
g.FillPolygon(bodyColor, new Point[] //up left wing
{
new Point(_startPosX + 36, _startPosY + 49),
new Point(_startPosX + 36, _startPosY + 1),
new Point(_startPosX + 45, _startPosY + 1),
new Point(_startPosX + 55, _startPosY + 49),
}
);
g.FillPolygon(bodyColor, new Point[] //down left wing
{
new Point(_startPosX + 36, _startPosY + 71),
new Point(_startPosX + 36, _startPosY + 116),
new Point(_startPosX + 45, _startPosY + 116),
new Point(_startPosX + 54, _startPosY + 71),
}
);
g.FillPolygon(wingsColor, new Point[] //up right wing
{
new Point(_startPosX + 120, _startPosY + 49),
new Point(_startPosX + 120, _startPosY + 42),
new Point(_startPosX + 140, _startPosY + 7),
new Point(_startPosX + 140, _startPosY + 49),
}
);
g.FillPolygon(wingsColor, new Point[] //down right wing
{
new Point(_startPosX + 120, _startPosY + 70),
new Point(_startPosX + 120, _startPosY + 77),
new Point(_startPosX + 140, _startPosY + 112),
new Point(_startPosX + 140, _startPosY + 70),
}
);
g.DrawPolygon(pen, new Point[] //nose
{
new Point(_startPosX + 20, _startPosY + 49),
new Point(_startPosX + 20, _startPosY + 70),
new Point(_startPosX, _startPosY + 59),
}
);
g.DrawRectangle(pen, _startPosX + 19, _startPosY + 49, 121, 21); //body
g.DrawPolygon(pen, new Point[] //up left wing
{
new Point(_startPosX + 35, _startPosY + 49),
new Point(_startPosX + 35, _startPosY),
new Point(_startPosX + 45, _startPosY),
new Point(_startPosX + 55, _startPosY + 49),
}
);
g.DrawPolygon(pen, new Point[] //down left wing
{
new Point(_startPosX + 36, _startPosY + 71),
new Point(_startPosX + 36, _startPosY + 116),
new Point(_startPosX + 45, _startPosY + 116),
new Point(_startPosX + 54, _startPosY + 71),
}
);
g.DrawPolygon(pen, new Point[] //up right wing
{
new Point(_startPosX + 120, _startPosY + 49),
new Point(_startPosX + 120, _startPosY + 42),
new Point(_startPosX + 140, _startPosY + 7),
new Point(_startPosX + 140, _startPosY + 49),
}
);
g.DrawPolygon(pen, new Point[] //down right wing
{
new Point(_startPosX + 120, _startPosY + 70),
new Point(_startPosX + 120, _startPosY + 77),
new Point(_startPosX + 140, _startPosY + 112),
new Point(_startPosX + 140, _startPosY + 70),
}
);
drawningEngines.DrawEngines(g, _startPosX, _startPosY);
}
public int GetPosX => _startPosX;
public int GetPosY => _startPosY;
public int GetWidth => _airPlaneWidth;
public int GetHeight => _airPlaneHeight;
public bool CanMove(DirectionType direction)
{
if (EntityAirPlane == null)
{
return false;
}
return direction switch
{
//влево
DirectionType.Left => _startPosX - EntityAirPlane.Step > 0,
//вверх
DirectionType.Up => _startPosY - EntityAirPlane.Step > 0,
// вправо
DirectionType.Right => _startPosX + EntityAirPlane.Step + _airPlaneWidth < _pictureWidth,
//вниз
DirectionType.Down => _startPosY + EntityAirPlane.Step + _airPlaneHeight < _pictureHeight,
_ => false,
};
}
public void MovePlane(DirectionType direction)
{
if (!CanMove(direction) || EntityAirPlane == null)
{
return;
}
switch (direction)
{
case DirectionType.Left:
_startPosX -= (int)EntityAirPlane.Step;
break;
case DirectionType.Up:
_startPosY -= (int)EntityAirPlane.Step;
break;
case DirectionType.Right:
_startPosX += (int)EntityAirPlane.Step;
break;
case DirectionType.Down:
_startPosY += (int)EntityAirPlane.Step;
break;
}
}
public IMoveableObject GetMoveableObject => new DrawningObjectAirPlane(this);
}
}

View File

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class DrawningEnginesCircle : IDrawningEngines
{
private Engines amount;
public int GetShape()
{
return 2;
}
public int GetAmount()
{
int x = 0;
if (amount == Engines.Two)
x = 2;
if (amount == Engines.Four)
x = 4;
if (amount == Engines.Six)
x = 6;
return x;
}
public void SetAmount(int a)
{
if (a <= 2)
{
amount = Engines.Two;
}
else if (a == 4)
{
amount = Engines.Four;
}
else if (a >= 6)
{
amount = Engines.Six;
}
}
public void DrawEngines(Graphics g, int _startPosX, int _startPosY)
{
Brush enginesColor = new SolidBrush(Color.Black);
g.FillPolygon(enginesColor, new Point[] //two up
{
new Point(_startPosX + 51, _startPosY + 30),
new Point(_startPosX + 75, _startPosY + 30),
new Point(_startPosX + 75, _startPosY + 40),
new Point(_startPosX + 53, _startPosY + 40),
}
);
g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 28, 13, 13);
g.FillPolygon(enginesColor, new Point[] //two down
{
new Point(_startPosX + 52, _startPosY + 80),
new Point(_startPosX + 75, _startPosY + 80),
new Point(_startPosX + 75, _startPosY + 90),
new Point(_startPosX + 50, _startPosY + 90),
}
);
g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 78, 13, 13);
if (amount == Engines.Four || amount == Engines.Six)
{
g.FillPolygon(enginesColor, new Point[] //four up
{
new Point(_startPosX + 48, _startPosY + 18),
new Point(_startPosX + 75, _startPosY + 18),
new Point(_startPosX + 75, _startPosY + 28),
new Point(_startPosX + 50, _startPosY + 28),
}
);
g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 16, 13, 13);
g.FillPolygon(enginesColor, new Point[] //four down
{
new Point(_startPosX + 49, _startPosY + 92),
new Point(_startPosX + 75, _startPosY + 92),
new Point(_startPosX + 75, _startPosY + 102),
new Point(_startPosX + 47, _startPosY + 102),
}
);
g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 90, 13, 13);
}
if (amount == Engines.Six)
{
g.FillPolygon(enginesColor, new Point[] //six up
{
new Point(_startPosX + 46, _startPosY + 6),
new Point(_startPosX + 75, _startPosY + 6),
new Point(_startPosX + 75, _startPosY + 16),
new Point(_startPosX + 48, _startPosY + 16),
}
);
g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 4, 13, 13);
g.FillPolygon(enginesColor, new Point[] //six down
{
new Point(_startPosX + 47, _startPosY + 104),
new Point(_startPosX + 75, _startPosY + 104),
new Point(_startPosX + 75, _startPosY + 114),
new Point(_startPosX + 45, _startPosY + 114),
}
);
g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 102, 13, 13);
}
}
}
}

View File

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class DrawningEnginesRectangle : IDrawningEngines
{
private Engines amount;
public int GetShape()
{
return 0;
}
public int GetAmount()
{
int x = 0;
if (amount == Engines.Two)
x = 2;
if (amount == Engines.Four)
x = 4;
if (amount == Engines.Six)
x = 6;
return x;
}
public void SetAmount(int a)
{
if (a <= 2)
{
amount = Engines.Two;
}
else if (a == 4)
{
amount = Engines.Four;
}
else if (a >= 6)
{
amount = Engines.Six;
}
}
public void DrawEngines(Graphics g, int _startPosX, int _startPosY)
{
Brush enginesColor = new SolidBrush(Color.Black);
g.FillPolygon(enginesColor, new Point[] //two up
{
new Point(_startPosX + 51, _startPosY + 30),
new Point(_startPosX + 75, _startPosY + 30),
new Point(_startPosX + 75, _startPosY + 40),
new Point(_startPosX + 53, _startPosY + 40),
}
);
g.FillPolygon(enginesColor, new Point[] //two down
{
new Point(_startPosX + 52, _startPosY + 80),
new Point(_startPosX + 75, _startPosY + 80),
new Point(_startPosX + 75, _startPosY + 90),
new Point(_startPosX + 50, _startPosY + 90),
}
);
if (amount == Engines.Four || amount == Engines.Six)
{
g.FillPolygon(enginesColor, new Point[] //four up
{
new Point(_startPosX + 48, _startPosY + 18),
new Point(_startPosX + 75, _startPosY + 18),
new Point(_startPosX + 75, _startPosY + 28),
new Point(_startPosX + 50, _startPosY + 28),
}
);
g.FillPolygon(enginesColor, new Point[] //four down
{
new Point(_startPosX + 49, _startPosY + 92),
new Point(_startPosX + 75, _startPosY + 92),
new Point(_startPosX + 75, _startPosY + 102),
new Point(_startPosX + 47, _startPosY + 102),
}
);
}
if (amount == Engines.Six)
{
g.FillPolygon(enginesColor, new Point[] //six up
{
new Point(_startPosX + 46, _startPosY + 6),
new Point(_startPosX + 75, _startPosY + 6),
new Point(_startPosX + 75, _startPosY + 16),
new Point(_startPosX + 48, _startPosY + 16),
}
);
g.FillPolygon(enginesColor, new Point[] //six down
{
new Point(_startPosX + 47, _startPosY + 104),
new Point(_startPosX + 75, _startPosY + 104),
new Point(_startPosX + 75, _startPosY + 114),
new Point(_startPosX + 45, _startPosY + 114),
}
);
}
}
}
}

View File

@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class DrawningEnginesTriangle : IDrawningEngines
{
private Engines amount;
public int GetShape()
{
return 1;
}
public int GetAmount()
{
int x = 0;
if (amount == Engines.Two)
x = 2;
if (amount == Engines.Four)
x = 4;
if (amount == Engines.Six)
x = 6;
return x;
}
public void SetAmount(int a)
{
if (a <= 2)
{
amount = Engines.Two;
}
else if (a == 4)
{
amount = Engines.Four;
}
else if (a >= 6)
{
amount = Engines.Six;
}
}
public void DrawEngines(Graphics g, int _startPosX, int _startPosY)
{
Brush enginesColor = new SolidBrush(Color.Black);
g.FillPolygon(enginesColor, new Point[] //two up
{
new Point(_startPosX + 51, _startPosY + 30),
new Point(_startPosX + 75, _startPosY + 30),
new Point(_startPosX + 75, _startPosY + 40),
new Point(_startPosX + 53, _startPosY + 40),
}
);
g.FillPolygon(enginesColor, new Point[] //two up TRIANGLE SHAPE
{
new Point(_startPosX + 73, _startPosY + 33),
new Point(_startPosX + 80, _startPosY + 28),
new Point(_startPosX + 80, _startPosY + 41),
}
);
g.FillPolygon(enginesColor, new Point[] //two down
{
new Point(_startPosX + 52, _startPosY + 80),
new Point(_startPosX + 75, _startPosY + 80),
new Point(_startPosX + 75, _startPosY + 90),
new Point(_startPosX + 50, _startPosY + 90),
}
);
g.FillPolygon(enginesColor, new Point[] //two down TRIANGLE SHAPE
{
new Point(_startPosX + 73, _startPosY + 83),
new Point(_startPosX + 80, _startPosY + 78),
new Point(_startPosX + 80, _startPosY + 91),
}
);
if (amount == Engines.Four || amount == Engines.Six)
{
g.FillPolygon(enginesColor, new Point[] //four up
{
new Point(_startPosX + 48, _startPosY + 18),
new Point(_startPosX + 75, _startPosY + 18),
new Point(_startPosX + 75, _startPosY + 28),
new Point(_startPosX + 50, _startPosY + 28),
}
);
g.FillPolygon(enginesColor, new Point[] //four up TRIANGLE SHAPE
{
new Point(_startPosX + 73, _startPosY + 23),
new Point(_startPosX + 80, _startPosY + 16),
new Point(_startPosX + 80, _startPosY + 27),
}
);
g.FillPolygon(enginesColor, new Point[] //four down
{
new Point(_startPosX + 49, _startPosY + 92),
new Point(_startPosX + 75, _startPosY + 92),
new Point(_startPosX + 75, _startPosY + 102),
new Point(_startPosX + 47, _startPosY + 102),
}
);
g.FillPolygon(enginesColor, new Point[] //four down TRIANGLE SHAPE
{
new Point(_startPosX + 73, _startPosY + 97),
new Point(_startPosX + 80, _startPosY + 92),
new Point(_startPosX + 80, _startPosY + 105),
}
);
}
if (amount == Engines.Six)
{
g.FillPolygon(enginesColor, new Point[] //six up
{
new Point(_startPosX + 46, _startPosY + 6),
new Point(_startPosX + 75, _startPosY + 6),
new Point(_startPosX + 75, _startPosY + 16),
new Point(_startPosX + 48, _startPosY + 16),
}
);
g.FillPolygon(enginesColor, new Point[] //six up TRIANGLE SHAPE
{
new Point(_startPosX + 73, _startPosY + 11),
new Point(_startPosX + 80, _startPosY + 5),
new Point(_startPosX + 80, _startPosY + 17),
}
);
g.FillPolygon(enginesColor, new Point[] //six down
{
new Point(_startPosX + 47, _startPosY + 104),
new Point(_startPosX + 75, _startPosY + 104),
new Point(_startPosX + 75, _startPosY + 114),
new Point(_startPosX + 45, _startPosY + 114),
}
);
g.FillPolygon(enginesColor, new Point[] //six down TRIANGLE SHAPE
{
new Point(_startPosX + 73, _startPosY + 109),
new Point(_startPosX + 80, _startPosY + 103),
new Point(_startPosX + 80, _startPosY + 115),
}
);
}
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class DrawningObjectAirPlane : IMoveableObject
{
private readonly DrawningAirPlane? _drawningAirPlane = null;
public DrawningObjectAirPlane(DrawningAirPlane drawningAirPlane)
{
_drawningAirPlane = drawningAirPlane;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawningAirPlane == null || _drawningAirPlane.EntityAirPlane == null)
{
return null;
}
return new ObjectParameters(_drawningAirPlane.GetPosX, _drawningAirPlane.GetPosY, _drawningAirPlane.GetWidth, _drawningAirPlane.GetHeight);
}
}
public int GetStep => (int)(_drawningAirPlane?.EntityAirPlane?.Step ?? 0);
public bool CheckCanMove(DirectionType direction) => _drawningAirPlane?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) => _drawningAirPlane?.MovePlane(direction);
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public enum Engines
{
Two,
Four,
Six
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class EntityAirBomber : EntityAirPlane
{
public Color AdditionalColor { get; private set; }
public bool Bombs { get; private set; }
public bool FuelTanks { get; private set; }
public EntityAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
Bombs = bombs;
FuelTanks = fuelTanks;
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class EntityAirPlane
{
public int Speed { get; private set; }
public double Weight { get; private set; }
public Color BodyColor { get; private set; }
public double Step => (double)Speed * 100 / Weight;
public EntityAirPlane(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
}
}
}

View File

@ -1,39 +0,0 @@
namespace AirBomber
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace AirBomber
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,73 @@
namespace AirBomber
{
partial class FormAdditionalGeneric
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
pictureBoxObject = new PictureBox();
buttonCreate = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
SuspendLayout();
//
// pictureBoxObject
//
pictureBoxObject.Dock = DockStyle.Fill;
pictureBoxObject.Location = new Point(0, 0);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(908, 460);
pictureBoxObject.TabIndex = 0;
pictureBoxObject.TabStop = false;
//
// buttonCreate
//
buttonCreate.Location = new Point(726, 28);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(152, 66);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += buttonCreate_Click;
//
// FormAdditionalGeneric
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(908, 460);
Controls.Add(buttonCreate);
Controls.Add(pictureBoxObject);
Name = "FormAdditionalGeneric";
Text = "Генерация самолетов";
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
ResumeLayout(false);
}
#endregion
private PictureBox pictureBoxObject;
private Button buttonCreate;
}
}

View File

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
namespace AirBomber
{
public partial class FormAdditionalGeneric : Form
{
private DrawningAirPlane _drawningAirPlane;
private AdditionalGeneric<EntityAirPlane, IDrawningEngines> additionalGeneric;
private readonly int _pictureWidth = 400;
private readonly int _pictureHeight = 400;
Random random = new Random();
public FormAdditionalGeneric()
{
InitializeComponent();
}
private void Draw()
{
if (_drawningAirPlane == null)
{
return;
}
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningAirPlane.DrawPlane(gr);
pictureBoxObject.Image = bmp;
}
private void buttonCreate_Click(object sender, EventArgs e)
{
int size = random.Next(1, 10);
additionalGeneric = new AdditionalGeneric<EntityAirPlane, IDrawningEngines>(size, _pictureWidth, _pictureHeight);
for (int i = 0; i < size; i++)
{
EntityAirPlane plane = CreateRandomPlane();
IDrawningEngines engines = CreateRandomEngines();
additionalGeneric.Add(plane);
additionalGeneric.Add(engines);
_drawningAirPlane = additionalGeneric.CreateDrawObject();
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
}
public EntityAirPlane CreateRandomPlane()
{
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
EntityAirPlane plane;
switch (random.Next(0, 2))
{
case 1:
plane = new EntityAirBomber(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(2)), Convert.ToBoolean(random.Next(2)));
break;
default:
plane = new EntityAirPlane(random.Next(100, 300), random.Next(1000, 3000), color);
break;
}
return plane;
}
public IDrawningEngines CreateRandomEngines()
{
IDrawningEngines engines;
switch (random.Next(3))
{
case 1:
engines = new DrawningEnginesTriangle();
break;
case 2:
engines = new DrawningEnginesCircle();
break;
default:
engines = new DrawningEnginesRectangle();
break;
}
engines.SetAmount((random.Next(1, 4) * 2));
return engines;
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,188 @@
namespace AirBomber
{
partial class FormAirBomber
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonCreateAirBomber = new Button();
buttonLeft = new Button();
buttonRight = new Button();
buttonUp = new Button();
buttonDown = new Button();
pictureBoxAirBomber = new PictureBox();
buttonCreateAirPlane = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
buttonSelectPlane = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit();
SuspendLayout();
//
// buttonCreateAirBomber
//
buttonCreateAirBomber.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateAirBomber.Location = new Point(40, 343);
buttonCreateAirBomber.Name = "buttonCreateAirBomber";
buttonCreateAirBomber.Size = new Size(186, 66);
buttonCreateAirBomber.TabIndex = 0;
buttonCreateAirBomber.Text = "Создать бомбардировщик";
buttonCreateAirBomber.UseVisualStyleBackColor = true;
buttonCreateAirBomber.Click += buttonCreateAirBomber_Click;
//
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
buttonLeft.Location = new Point(581, 364);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(45, 45);
buttonLeft.TabIndex = 1;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += buttonMove_Click;
//
// buttonRight
//
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.arrowRight1;
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
buttonRight.Location = new Point(706, 364);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(45, 45);
buttonRight.TabIndex = 2;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += buttonMove_Click;
//
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
buttonUp.Location = new Point(644, 301);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(45, 45);
buttonUp.TabIndex = 3;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += buttonMove_Click;
//
// buttonDown
//
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
buttonDown.Location = new Point(644, 364);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(45, 45);
buttonDown.TabIndex = 4;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += buttonMove_Click;
//
// pictureBoxAirBomber
//
pictureBoxAirBomber.Dock = DockStyle.Fill;
pictureBoxAirBomber.Location = new Point(0, 0);
pictureBoxAirBomber.Name = "pictureBoxAirBomber";
pictureBoxAirBomber.Size = new Size(800, 450);
pictureBoxAirBomber.TabIndex = 5;
pictureBoxAirBomber.TabStop = false;
//
// buttonCreateAirPlane
//
buttonCreateAirPlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateAirPlane.Location = new Point(248, 343);
buttonCreateAirPlane.Name = "buttonCreateAirPlane";
buttonCreateAirPlane.Size = new Size(186, 66);
buttonCreateAirPlane.TabIndex = 6;
buttonCreateAirPlane.Text = "Создать самолёт";
buttonCreateAirPlane.UseVisualStyleBackColor = true;
buttonCreateAirPlane.Click += buttonCreateAirPlane_Click;
//
// comboBoxStrategy
//
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToBorder" });
comboBoxStrategy.Location = new Point(590, 21);
comboBoxStrategy.Name = "comboBoxStrategy";
comboBoxStrategy.Size = new Size(182, 33);
comboBoxStrategy.TabIndex = 7;
//
// buttonStrategyStep
//
buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonStrategyStep.Location = new Point(660, 70);
buttonStrategyStep.Name = "buttonStrategyStep";
buttonStrategyStep.Size = new Size(112, 34);
buttonStrategyStep.TabIndex = 8;
buttonStrategyStep.Text = "Шаг";
buttonStrategyStep.UseVisualStyleBackColor = true;
buttonStrategyStep.Click += buttonStrategyStep_Click;
//
// buttonSelectPlane
//
buttonSelectPlane.Location = new Point(660, 161);
buttonSelectPlane.Name = "buttonSelectPlane";
buttonSelectPlane.Size = new Size(112, 63);
buttonSelectPlane.TabIndex = 9;
buttonSelectPlane.Text = "Выбрать самолет";
buttonSelectPlane.UseVisualStyleBackColor = true;
buttonSelectPlane.Click += buttonSelectPlane_Click;
//
// FormAirBomber
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonSelectPlane);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonCreateAirPlane);
Controls.Add(buttonDown);
Controls.Add(buttonUp);
Controls.Add(buttonRight);
Controls.Add(buttonLeft);
Controls.Add(buttonCreateAirBomber);
Controls.Add(pictureBoxAirBomber);
Name = "FormAirBomber";
Text = "Бомбардировщик";
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonCreateAirBomber;
private Button buttonLeft;
private Button buttonRight;
private Button buttonUp;
private Button buttonDown;
private PictureBox pictureBoxAirBomber;
private Button buttonCreateAirPlane;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
private Button buttonSelectPlane;
}
}

View File

@ -0,0 +1,128 @@
namespace AirBomber
{
public partial class FormAirBomber : Form
{
private DrawningAirPlane? _drawningAirPlane;
private AbstractStrategy? _strategy;
public DrawningAirPlane? SelectedPlane { get; private set; }
public FormAirBomber()
{
InitializeComponent();
_strategy = null;
SelectedPlane = null;
}
private void Draw()
{
if (_drawningAirPlane == null)
{
return;
}
Bitmap bmp = new(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningAirPlane.DrawPlane(gr);
pictureBoxAirBomber.Image = bmp;
}
private void buttonCreateAirBomber_Click(object sender, EventArgs e)
{
Random random = new();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog colorDialog = new ColorDialog();
//TODO выбор основного цвета DONE
if (colorDialog.ShowDialog() == DialogResult.OK)
{
color = colorDialog.Color;
}
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
//TODO выбор дополнительного цвета DONE
if (colorDialog.ShowDialog() == DialogResult.OK)
{
dopColor = colorDialog.Color;
}
_drawningAirPlane = new DrawningAirBomber(random.Next(100, 300), random.Next(1000, 3000), color, dopColor,
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height, random.Next(1, 4) * 2, random.Next(0, 4));
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonCreateAirPlane_Click(object sender, EventArgs e)
{
Random random = new();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
_drawningAirPlane = new DrawningAirPlane(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxAirBomber.Width, pictureBoxAirBomber.Height, random.Next(1, 4) * 2, random.Next(0, 4));
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)
{
if (_drawningAirPlane == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_drawningAirPlane.MovePlane(DirectionType.Up);
break;
case "buttonDown":
_drawningAirPlane.MovePlane(DirectionType.Down);
break;
case "buttonLeft":
_drawningAirPlane.MovePlane(DirectionType.Left);
break;
case "buttonRight":
_drawningAirPlane.MovePlane(DirectionType.Right);
break;
}
Draw();
}
private void buttonStrategyStep_Click(object sender, EventArgs e)
{
if (_drawningAirPlane == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
_strategy = comboBoxStrategy.SelectedIndex
switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
if (_strategy == null)
{
return;
}
_strategy.SetData(new DrawningObjectAirPlane(_drawningAirPlane), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
comboBoxStrategy.Enabled = false;
}
if (_strategy == null)
{
return;
}
comboBoxStrategy.Enabled = false;
_strategy.MakeStep();
Draw();
if (_strategy.GetStatus() == Status.Finish)
{
comboBoxStrategy.Enabled = true;
_strategy = null;
}
}
private void buttonSelectPlane_Click(object sender, EventArgs e)
{
SelectedPlane = _drawningAirPlane;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,139 @@
namespace AirBomber
{
partial class FormPlaneCollection
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
buttonRefreshCollection = new Button();
buttonRemovePlane = new Button();
maskedTextBoxNumber = new MaskedTextBox();
buttonAddPlane = new Button();
pictureBoxCollection = new PictureBox();
buttonToFormAddGeneric = new Button();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(buttonToFormAddGeneric);
groupBoxTools.Controls.Add(buttonRefreshCollection);
groupBoxTools.Controls.Add(buttonRemovePlane);
groupBoxTools.Controls.Add(maskedTextBoxNumber);
groupBoxTools.Controls.Add(buttonAddPlane);
groupBoxTools.Location = new Point(758, 1);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(325, 655);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonRefreshCollection
//
buttonRefreshCollection.Location = new Point(17, 357);
buttonRefreshCollection.Name = "buttonRefreshCollection";
buttonRefreshCollection.Size = new Size(290, 59);
buttonRefreshCollection.TabIndex = 3;
buttonRefreshCollection.Text = "Обновить коллекцию";
buttonRefreshCollection.UseVisualStyleBackColor = true;
buttonRefreshCollection.Click += buttonRefreshCollection_Click;
//
// buttonRemovePlane
//
buttonRemovePlane.Location = new Point(17, 213);
buttonRemovePlane.Name = "buttonRemovePlane";
buttonRemovePlane.Size = new Size(290, 59);
buttonRemovePlane.TabIndex = 2;
buttonRemovePlane.Text = "Удалить самолет";
buttonRemovePlane.UseVisualStyleBackColor = true;
buttonRemovePlane.Click += buttonRemovePlane_Click;
//
// maskedTextBoxNumber
//
maskedTextBoxNumber.Location = new Point(79, 166);
maskedTextBoxNumber.Mask = "00";
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(171, 31);
maskedTextBoxNumber.TabIndex = 1;
maskedTextBoxNumber.ValidatingType = typeof(int);
//
// buttonAddPlane
//
buttonAddPlane.Location = new Point(17, 53);
buttonAddPlane.Name = "buttonAddPlane";
buttonAddPlane.Size = new Size(290, 59);
buttonAddPlane.TabIndex = 0;
buttonAddPlane.Text = "Добавить самолет";
buttonAddPlane.UseVisualStyleBackColor = true;
buttonAddPlane.Click += buttonAddPlane_Click;
//
// pictureBoxCollection
//
pictureBoxCollection.Dock = DockStyle.Left;
pictureBoxCollection.Location = new Point(0, 0);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(752, 668);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
// buttonToFormAddGeneric
//
buttonToFormAddGeneric.Location = new Point(17, 545);
buttonToFormAddGeneric.Name = "buttonToFormAddGeneric";
buttonToFormAddGeneric.Size = new Size(290, 61);
buttonToFormAddGeneric.TabIndex = 4;
buttonToFormAddGeneric.Text = "Перейти к генерации объектов";
buttonToFormAddGeneric.UseVisualStyleBackColor = true;
buttonToFormAddGeneric.Click += buttonToFormAddGeneric_Click;
//
// FormPlaneCollection
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1095, 668);
Controls.Add(pictureBoxCollection);
Controls.Add(groupBoxTools);
Name = "FormPlaneCollection";
Text = "Набор самолетов";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxTools;
private Button buttonRefreshCollection;
private Button buttonRemovePlane;
private MaskedTextBox maskedTextBoxNumber;
private Button buttonAddPlane;
private PictureBox pictureBoxCollection;
private Button buttonToFormAddGeneric;
}
}

View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AirBomber
{
public partial class FormPlaneCollection : Form
{
private readonly PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane> _planes;
public FormPlaneCollection()
{
InitializeComponent();
_planes = new PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane>(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
private void buttonAddPlane_Click(object sender, EventArgs e)
{
FormAirBomber form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (_planes + form.SelectedPlane != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _planes.ShowPlanes();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
private void buttonRemovePlane_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
if (_planes - pos != null)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _planes.ShowPlanes();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void buttonRefreshCollection_Click(object sender, EventArgs e)
{
pictureBoxCollection.Image = _planes.ShowPlanes();
}
private void buttonToFormAddGeneric_Click(object sender, EventArgs e)
{
FormAdditionalGeneric form = new();
form.ShowDialog();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public interface IDrawningEngines
{
public void SetAmount(int a);
public void DrawEngines(Graphics g, int _startPosX, int _startPosY);
public int GetAmount();
public int GetShape();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public interface IMoveableObject
{
ObjectParameters? GetObjectPosition { get; }
int GetStep { get; }
bool CheckCanMove(DirectionType direction);
void MoveObject(DirectionType direction);
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class MoveToBorder : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null) return false;
return objParams.RightBorder >= FieldWidth - GetStep() && objParams.DownBorder >= FieldHeight - GetStep();
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null) return;
if (objParams.RightBorder < FieldWidth - GetStep()) MoveRight();
if (objParams.DownBorder < FieldHeight - GetStep()) MoveDown();
}
}
}

View File

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class MoveToCenter : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
if (Math.Abs(diffX) > GetStep())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class ObjectParameters
{
private readonly int _x;
private readonly int _y;
private readonly int _width;
private readonly int _height;
public int LeftBorder => _x;
public int TopBorder => _y;
public int RightBorder => _x + _width;
public int DownBorder => _y + _height;
public int ObjectMiddleHorizontal => _x + _width / 2;
public int ObjectMiddleVertical => _y + _height / 2;
public ObjectParameters(int x, int y, int width, int height)
{
_x = x;
_y = y;
_width = width;
_height = height;
}
}
}

View File

@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal class PlanesGenericCollection<T, U>
where T : DrawningAirPlane
where U : IMoveableObject
{
private readonly int _pictureWidth;
private readonly int _pictureHeight;
private readonly int _placeSizeWidth = 170;
private readonly int _placeSizeHeight = 120;
private readonly SetGeneric<T> _collection;
public PlanesGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
public static int operator +(PlanesGenericCollection<T, U> collect, T? obj)
{
if (obj == null)
{
return -1;
}
return collect?._collection.Insert(obj) ?? -1;
}
public static bool operator -(PlanesGenericCollection<T, U> collect, int pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
{
collect._collection.Remove(pos);
return true;
}
return false;
}
public U? GetU(int pos)
{
return (U?)_collection.Get(pos)?.GetMoveableObject;
}
public Bitmap ShowPlanes()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawObjects(gr);
return bmp;
}
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
_placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
private void DrawObjects(Graphics g)
{
int widthObjCount = _pictureWidth / _placeSizeWidth;
for (int i = 0; i < _collection.Count; i++)
{
T? type = _collection.Get(i);
if (type != null)
{
int row = i / widthObjCount;
int col = widthObjCount - 1 - (i % widthObjCount);
type.SetPosition(col * _placeSizeWidth, row * _placeSizeHeight);
type?.DrawPlane(g);
}
}
}
}
}

View File

@ -1,4 +1,4 @@
namespace AirBomber namespace AirBomber
{ {
internal static class Program internal static class Program
{ {
@ -11,7 +11,7 @@ namespace AirBomber
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Form1()); Application.Run(new FormPlaneCollection());
} }
} }
} }

View File

@ -0,0 +1,113 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AirBomber.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AirBomber.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowDown {
get {
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowLeft {
get {
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowRight {
get {
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowRight1 {
get {
object obj = ResourceManager.GetObject("arrowRight1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowUp {
get {
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -117,4 +117,20 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowRight1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowRight1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal class SetGeneric<T>
where T : class
{
private readonly T?[] _places;
public int Count => _places.Length;
public SetGeneric(int count)
{
_places = new T?[count];
}
public int Insert(T plane)
{
return Insert(plane, 0);
}
public int Insert(T plane, int position)
{
int NoEmpty = 0, temp = 0;
for (int i = position; i < Count; i++)
{
if (_places[i] != null) NoEmpty++;
}
if (NoEmpty == Count - position) return -1;
if (position < Count && position >= 0)
{
for (int j = position; j < Count; j++)
{
if (_places[j] == null)
{
temp = j;
break;
}
}
for (int i = temp; i > position; i--)
{
_places[i] = _places[i - 1];
}
_places[position] = plane;
return position;
}
return -1;
}
public bool Remove(int position)
{
if (!(position >= 0 && position < Count) || _places[position] == null)
{
return false;
}
_places[position] = null;
return true;
}
public T? Get(int position)
{
if (position < 0 || position >= Count)
{
return null;
}
return _places[position];
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public enum Status
{
NotInit,
InProgress,
Finish
}
}