Лабораторная работа №2

This commit is contained in:
Egor_Shtyrkin 2024-04-25 18:09:11 +04:00
parent 6d9ac5d186
commit d5a506cd3a
3 changed files with 9 additions and 15 deletions

View File

@ -17,28 +17,25 @@ public class DrawningAircraftCarrier : DrawningWarship
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="aircraftDeck">Признак наличия взлётно-посадочной полосы</param>
/// <param name="controlRoom">Признак наличия рубки управления</param>
public DrawningAircraftCarrier(int speed, double weight, Color bodyColor, Color additionalColor, bool aircraftDeck, bool controlRoom) : base(145, 55)
public DrawningAircraftCarrier(int speed, double weight, Color bodyColor, Color additionalColor, bool aircraftDeck, bool controlRoom) : base(145, 57)
{
EntityWarship = new EntityAircraftCarrier(speed, weight, bodyColor, additionalColor, aircraftDeck, controlRoom);
}
public override void DrawTransport(Graphics g)
{
if (EntityWarship == null || EntityWarship is not EntityAircraftCarrier warship || !_startPosX.HasValue || !_startPosY.HasValue)
if (EntityWarship == null || EntityWarship is not EntityAircraftCarrier aircraftcarrier || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(warship.AdditionalColor);
Brush additionalBrush = new SolidBrush(aircraftcarrier.AdditionalColor);
_startPosX += 5;
_startPosY += 10;
base.DrawTransport(g);
//рубка управления
if (warship.ControlRoom)
if (aircraftcarrier.ControlRoom)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 42, 15, 15);
g.FillRectangle(additionalBrush, _startPosX.Value + 65, _startPosY.Value + 42, 15, 15);
@ -56,7 +53,7 @@ public class DrawningAircraftCarrier : DrawningWarship
}
//палуба для взлёта самолётов
if (warship.AircraftDeck)
if (aircraftcarrier.AircraftDeck)
{
Point[] DeckPoint =
{
@ -68,9 +65,6 @@ public class DrawningAircraftCarrier : DrawningWarship
g.FillPolygon(additionalBrush, DeckPoint);
g.DrawPolygon(pen, DeckPoint);
g.DrawLine(pen, _startPosX.Value + 5, _startPosY.Value + 35, _startPosX.Value + 50, _startPosY.Value + 10);
_startPosX -= 5;
_startPosX -= 10;
}
}
}

View File

@ -94,10 +94,10 @@ public class DrawningWarship
/// </summary>
/// <param name="drawningWarshipWidth">Ширина прорисовки военного корабля</param>
/// <param name="drawningWarshipHeight">Высота прорисовки военного корабля</param>
protected DrawningWarship(int drawningAircraftCarrierWidth, int drawningAircraftCarrierHeight) : this()
protected DrawningWarship(int drawningWarshipWidth, int drawningWarshipHeight) : this()
{
_drawningWarshipWidth = drawningAircraftCarrierWidth;
_drawningWarshipHeight = drawningAircraftCarrierHeight;
_drawningWarshipWidth = drawningWarshipWidth;
_drawningWarshipHeight = drawningWarshipHeight;
}
/// <summary>

View File

@ -145,7 +145,7 @@ public partial class FormAircraftCarrier : Form
_strategy = comboBoxStrategy.SelectedIndex switch
{
0 => new MoveToCenter(),
1 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
if(_strategy == null)