change names of variables to correct

This commit is contained in:
ZakenChannel 2024-04-06 16:17:20 +04:00
parent 46ab512462
commit ed2d1ac174
12 changed files with 58 additions and 58 deletions

View File

@ -30,7 +30,7 @@ public abstract class AbstractCompany
/// <summary>
/// Коллекция автомобилей
/// </summary>
protected ICollectionGenericObjects<DrawningFighter>? _collection = null;
protected ICollectionGenericObjects<DrawningWarPlane>? _collection = null;
/// <summary>
/// Вычисление максимального количества элементов, который можно разместить в окне
@ -43,7 +43,7 @@ public abstract class AbstractCompany
/// <param name="picWidth">Ширина окна</param>
/// <param name="picHeight">Высота окна</param>
/// <param name="collection">Коллекция автомобилей</param>
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningFighter> collection)
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningWarPlane> collection)
{
_pictureWidth = picWidth;
_pictureHeight = picHeight;
@ -57,13 +57,13 @@ public abstract class AbstractCompany
/// <param name="company">Компания</param>
/// <param name="car">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningFighter fighter)
public static int operator +(AbstractCompany company, DrawningWarPlane plane)
{
if (company._collection == null)
{
return -1;
}
return company._collection.Insert(fighter);
return company._collection.Insert(plane);
}
/// <summary>
@ -72,7 +72,7 @@ public abstract class AbstractCompany
/// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns>
public static DrawningFighter operator -(AbstractCompany company, int position)
public static DrawningWarPlane operator -(AbstractCompany company, int position)
{
return company._collection?.Remove(position) ?? null;
}
@ -82,7 +82,7 @@ public abstract class AbstractCompany
/// Получение случайного объекта из коллекции
/// </summary>
/// <returns></returns>
public DrawningFighter? GetRandomObject()
public DrawningWarPlane? GetRandomObject()
{
Random rnd = new();
return _collection?.Get(rnd.Next(GetMaxCount));
@ -101,7 +101,7 @@ public abstract class AbstractCompany
SetObjectsPosition();
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
{
DrawningFighter? obj = _collection?.Get(i);
DrawningWarPlane? obj = _collection?.Get(i);
obj?.DrawTransport(graphics);
}

View File

@ -13,7 +13,7 @@ public class Hangar : AbstractCompany
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
public Hangar(int picWidth, int picHeight, ICollectionGenericObjects<DrawningFighter> collection) : base(picWidth, picHeight, collection)
public Hangar(int picWidth, int picHeight, ICollectionGenericObjects<DrawningWarPlane> collection) : base(picWidth, picHeight, collection)
{
}

View File

@ -5,7 +5,7 @@ namespace ProjectAirFighter.Drawnings;
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningAirFighter : DrawningFighter
public class DrawningAirFighter : DrawningWarPlane
{
/// <summary>
/// Конструктор

View File

@ -2,13 +2,13 @@
namespace ProjectAirFighter.Drawnings;
public class DrawningFighter
public class DrawningWarPlane
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityFighter? EntityFighter { get; protected set; }
public EntityWarPlane? EntityFighter { get; protected set; }
/// <summary>
/// Ширина окна
@ -63,7 +63,7 @@ public class DrawningFighter
/// <summary>
/// Пустой конструктор
/// </summary>
protected DrawningFighter()
protected DrawningWarPlane()
{
_pictureWidth = null;
_pictureHeight = null;
@ -77,9 +77,9 @@ public class DrawningFighter
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
public DrawningFighter(int speed, double weight, Color bodyColor) : this()
public DrawningWarPlane(int speed, double weight, Color bodyColor) : this()
{
EntityFighter = new EntityFighter(speed, weight, bodyColor);
EntityFighter = new EntityWarPlane(speed, weight, bodyColor);
}
/// <summary>

View File

@ -3,7 +3,7 @@
/// <summary>
/// Класс-сущность "Истребитель"
/// </summary>
public class EntityAirFighter : EntityFighter
public class EntityAirFighter : EntityWarPlane
{
/// <summary>

View File

@ -3,7 +3,7 @@
/// <summary>
/// Класс-сущность "Истребитель без доп опций"
/// </summary>
public class EntityFighter
public class EntityWarPlane
{
/// <summary>
/// Скорость
@ -31,7 +31,7 @@ public class EntityFighter
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес истребителя</param>
/// <param name="bodyColor">Основной цвет</param>
public EntityFighter(int speed, double weight, Color bodyColor)
public EntityWarPlane(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;

View File

@ -13,7 +13,7 @@ public partial class FormAirFighter : Form
/// <summary>
/// Поле-объект для прорисовки объекта
/// </summary>
private DrawningFighter? _drawningFighter;
private DrawningWarPlane? _drawningWarPlane;
/// <summary>
/// Стратегия перемещения
@ -23,12 +23,12 @@ public partial class FormAirFighter : Form
/// <summary>
/// Получение объекта
/// </summary>
public DrawningFighter SetFighter
public DrawningWarPlane SetWarPlane
{
set
{
_drawningFighter = value;
_drawningFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
_drawningWarPlane = value;
_drawningWarPlane.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
comboBoxStrategy.Enabled = true;
_strategy = null;
Draw();
@ -49,14 +49,14 @@ public partial class FormAirFighter : Form
/// </summary>
private void Draw()
{
if (_drawningFighter == null)
if (_drawningWarPlane == null)
{
return;
}
if (pictureBoxAirFighter.Width == 0 || pictureBoxAirFighter.Height == 0) return;
Bitmap bitmap = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
Graphics gr = Graphics.FromImage(bitmap);
_drawningFighter?.DrawTransport(gr);
_drawningWarPlane?.DrawTransport(gr);
pictureBoxAirFighter.Image = bitmap;
}
@ -67,7 +67,7 @@ public partial class FormAirFighter : Form
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawningFighter == null)
if (_drawningWarPlane == null)
{
return;
}
@ -77,19 +77,19 @@ public partial class FormAirFighter : Form
switch (name)
{
case "buttonUp":
result = _drawningFighter.MoveTransport(DirectionType.Up);
result = _drawningWarPlane.MoveTransport(DirectionType.Up);
break;
case "buttonLeft":
result = _drawningFighter.MoveTransport(DirectionType.Left);
result = _drawningWarPlane.MoveTransport(DirectionType.Left);
break;
case "buttonDown":
result = _drawningFighter.MoveTransport(DirectionType.Down);
result = _drawningWarPlane.MoveTransport(DirectionType.Down);
break;
case "buttonRight":
result = _drawningFighter.MoveTransport(DirectionType.Right);
result = _drawningWarPlane.MoveTransport(DirectionType.Right);
break;
}
if (result) Draw();
@ -97,13 +97,13 @@ public partial class FormAirFighter : Form
private void PictureBox_Resize(object sender, EventArgs e)
{
_drawningFighter?.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
_drawningWarPlane?.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
Draw();
}
private void ButtonStrategyStep_Click(object sender, EventArgs e)
{
if (_drawningFighter == null) return;
if (_drawningWarPlane == null) return;
if (comboBoxStrategy.Enabled)
{
_strategy = comboBoxStrategy.SelectedIndex switch
@ -113,7 +113,7 @@ public partial class FormAirFighter : Form
_ => null,
};
if (_strategy == null) return;
_strategy.SetData(new MoveableFighter(_drawningFighter), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
_strategy.SetData(new MoveablePlane(_drawningWarPlane), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
}
if (_strategy == null) return;
comboBoxStrategy.Enabled = false;

View File

@ -1,6 +1,6 @@
namespace ProjectAirFighter
{
partial class FormFighterCollection
partial class FormWarPlaneCollection
{
/// <summary>
/// Required designer variable.

View File

@ -6,7 +6,7 @@ namespace ProjectAirFighter;
/// <summary>
/// Форма работы с компанией и ее коллекцией
/// </summary>
public partial class FormFighterCollection : Form
public partial class FormWarPlaneCollection : Form
{
/// <summary>
/// Компания
@ -16,7 +16,7 @@ public partial class FormFighterCollection : Form
/// <summary>
/// Конструктор
/// </summary>
public FormFighterCollection()
public FormWarPlaneCollection()
{
InitializeComponent();
}
@ -31,7 +31,7 @@ public partial class FormFighterCollection : Form
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new Hangar(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningFighter>());
_company = new Hangar(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningWarPlane>());
break;
}
}
@ -45,20 +45,20 @@ public partial class FormFighterCollection : Form
if (_company == null) return;
Random random = new();
DrawningFighter drawningFighter;
DrawningWarPlane drawningWarPlane;
switch (type)
{
case nameof(DrawningFighter):
drawningFighter = new DrawningFighter(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
case nameof(DrawningWarPlane):
drawningWarPlane = new DrawningWarPlane(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningAirFighter):
drawningFighter = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000),
drawningWarPlane = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000),
GetColor(random), GetColor(random), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + drawningFighter != -1)
if (_company + drawningWarPlane != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -91,7 +91,7 @@ public partial class FormFighterCollection : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningFighter));
private void ButtonAddFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarPlane));
/// <summary>
/// Добавление истребителя с доп элементами
@ -151,11 +151,11 @@ public partial class FormFighterCollection : Form
return;
}
DrawningFighter? fighter = null;
DrawningWarPlane? warPlane = null;
int counter = 100;
while (fighter == null)
while (warPlane == null)
{
fighter = _company.GetRandomObject();
warPlane = _company.GetRandomObject();
counter--;
if (counter <= 0)
{
@ -163,14 +163,14 @@ public partial class FormFighterCollection : Form
}
}
if (fighter == null)
if (warPlane == null)
{
return;
}
FormAirFighter form = new()
{
SetFighter = fighter
SetWarPlane = warPlane
};
form.ShowDialog();
}

View File

@ -5,45 +5,45 @@ namespace ProjectAirFighter.MovementStrategy;
/// <summary>
/// Класс-реализация IMoveableObject с использованием DrawningCar
/// </summary>
public class MoveableFighter : IMoveableObject
public class MoveablePlane : IMoveableObject
{
/// <summary>
/// Поле-объект класса DrawningFighter или его наследника
/// Поле-объект класса DrawningWarPlane или его наследника
/// </summary>
private readonly DrawningFighter? _fighter = null;
private readonly DrawningWarPlane? _warPlane = null;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="drawningFighter"></param>
public MoveableFighter(DrawningFighter drawningFighter)
/// <param name="drawningWarPlane"></param>
public MoveablePlane(DrawningWarPlane drawningWarPlane)
{
_fighter = drawningFighter;
_warPlane = drawningWarPlane;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_fighter == null || _fighter.EntityFighter == null || !_fighter.GetPosX.HasValue || !_fighter.GetPosY.HasValue)
if (_warPlane == null || _warPlane.EntityFighter == null || !_warPlane.GetPosX.HasValue || !_warPlane.GetPosY.HasValue)
{
return null;
}
return new ObjectParameters(_fighter.GetPosX.Value, _fighter.GetPosY.Value, _fighter.GetWidth.Value, _fighter.GetHeight.Value);
return new ObjectParameters(_warPlane.GetPosX.Value, _warPlane.GetPosY.Value, _warPlane.GetWidth.Value, _warPlane.GetHeight.Value);
}
}
public int GetStep => (int)(_fighter?.EntityFighter?.Step ?? 0);
public int GetStep => (int)(_warPlane?.EntityFighter?.Step ?? 0);
public bool TryMoveObject(MovementDiraction direction)
{
if (_fighter == null || _fighter.EntityFighter == null)
if (_warPlane == null || _warPlane.EntityFighter == null)
{
return false;
}
return _fighter.MoveTransport(GetDirectionType(direction));
return _warPlane.MoveTransport(GetDirectionType(direction));
}
/// <summary>

View File

@ -11,7 +11,7 @@ namespace ProjectAirFighter
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormFighterCollection());
Application.Run(new FormWarPlaneCollection());
}
}
}