diff --git a/ProjectAirFighter/ProjectAirFighter/CollectionGenericObjects/AbstractCompany.cs b/ProjectAirFighter/ProjectAirFighter/CollectionGenericObjects/AbstractCompany.cs index 8b2575a..2a308f8 100644 --- a/ProjectAirFighter/ProjectAirFighter/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectAirFighter/ProjectAirFighter/CollectionGenericObjects/AbstractCompany.cs @@ -30,7 +30,7 @@ public abstract class AbstractCompany /// /// Коллекция автомобилей /// - protected ICollectionGenericObjects? _collection = null; + protected ICollectionGenericObjects? _collection = null; /// /// Вычисление максимального количества элементов, который можно разместить в окне @@ -43,7 +43,7 @@ public abstract class AbstractCompany /// Ширина окна /// Высота окна /// Коллекция автомобилей - public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection) + public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection) { _pictureWidth = picWidth; _pictureHeight = picHeight; @@ -57,13 +57,13 @@ public abstract class AbstractCompany /// Компания /// Добавляемый объект /// - 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); } /// @@ -72,7 +72,7 @@ public abstract class AbstractCompany /// Компания /// Номер удаляемого объекта /// - 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 /// Получение случайного объекта из коллекции /// /// - 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); } diff --git a/ProjectAirFighter/ProjectAirFighter/CollectionGenericObjects/Hangar.cs b/ProjectAirFighter/ProjectAirFighter/CollectionGenericObjects/Hangar.cs index f44a447..5cf9605 100644 --- a/ProjectAirFighter/ProjectAirFighter/CollectionGenericObjects/Hangar.cs +++ b/ProjectAirFighter/ProjectAirFighter/CollectionGenericObjects/Hangar.cs @@ -13,7 +13,7 @@ public class Hangar : AbstractCompany /// /// /// - public Hangar(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) + public Hangar(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) { } diff --git a/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningAirFighter.cs index 24579bb..26e6cef 100644 --- a/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningAirFighter.cs @@ -5,7 +5,7 @@ namespace ProjectAirFighter.Drawnings; /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности /// -public class DrawningAirFighter : DrawningFighter +public class DrawningAirFighter : DrawningWarPlane { /// /// Конструктор diff --git a/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningFighter.cs b/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningWarPlane.cs similarity index 96% rename from ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningFighter.cs rename to ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningWarPlane.cs index 16a48da..b4163de 100644 --- a/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/Drawnings/DrawningWarPlane.cs @@ -2,13 +2,13 @@ namespace ProjectAirFighter.Drawnings; -public class DrawningFighter +public class DrawningWarPlane { /// /// Класс-сущность /// - public EntityFighter? EntityFighter { get; protected set; } + public EntityWarPlane? EntityFighter { get; protected set; } /// /// Ширина окна @@ -63,7 +63,7 @@ public class DrawningFighter /// /// Пустой конструктор /// - protected DrawningFighter() + protected DrawningWarPlane() { _pictureWidth = null; _pictureHeight = null; @@ -77,9 +77,9 @@ public class DrawningFighter /// Скорость /// Вес /// Основной цвет - 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); } /// diff --git a/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs index ab9de4a..59889c3 100644 --- a/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs @@ -3,7 +3,7 @@ /// /// Класс-сущность "Истребитель" /// -public class EntityAirFighter : EntityFighter +public class EntityAirFighter : EntityWarPlane { /// diff --git a/ProjectAirFighter/ProjectAirFighter/Entities/EntityFighter.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs similarity index 90% rename from ProjectAirFighter/ProjectAirFighter/Entities/EntityFighter.cs rename to ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs index 11975ae..87ee0c0 100644 --- a/ProjectAirFighter/ProjectAirFighter/Entities/EntityFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs @@ -3,7 +3,7 @@ /// /// Класс-сущность "Истребитель без доп опций" /// -public class EntityFighter +public class EntityWarPlane { /// /// Скорость @@ -31,7 +31,7 @@ public class EntityFighter /// Скорость /// Вес истребителя /// Основной цвет - public EntityFighter(int speed, double weight, Color bodyColor) + public EntityWarPlane(int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight; diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs index 9182c7a..a57d679 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs @@ -13,7 +13,7 @@ public partial class FormAirFighter : Form /// /// Поле-объект для прорисовки объекта /// - private DrawningFighter? _drawningFighter; + private DrawningWarPlane? _drawningWarPlane; /// /// Стратегия перемещения @@ -23,12 +23,12 @@ public partial class FormAirFighter : Form /// /// Получение объекта /// - 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 /// 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 /// 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; diff --git a/ProjectAirFighter/ProjectAirFighter/FormFighterCollection.Designer.cs b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs similarity index 99% rename from ProjectAirFighter/ProjectAirFighter/FormFighterCollection.Designer.cs rename to ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs index cc452f2..fa03336 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormFighterCollection.Designer.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.Designer.cs @@ -1,6 +1,6 @@ namespace ProjectAirFighter { - partial class FormFighterCollection + partial class FormWarPlaneCollection { /// /// Required designer variable. diff --git a/ProjectAirFighter/ProjectAirFighter/FormFighterCollection.cs b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs similarity index 85% rename from ProjectAirFighter/ProjectAirFighter/FormFighterCollection.cs rename to ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs index 15dbe90..414181b 100644 --- a/ProjectAirFighter/ProjectAirFighter/FormFighterCollection.cs +++ b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.cs @@ -6,7 +6,7 @@ namespace ProjectAirFighter; /// /// Форма работы с компанией и ее коллекцией /// -public partial class FormFighterCollection : Form +public partial class FormWarPlaneCollection : Form { /// /// Компания @@ -16,7 +16,7 @@ public partial class FormFighterCollection : Form /// /// Конструктор /// - 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()); + _company = new Hangar(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); 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 /// /// /// - private void ButtonAddFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningFighter)); + private void ButtonAddFighter_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarPlane)); /// /// Добавление истребителя с доп элементами @@ -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(); } diff --git a/ProjectAirFighter/ProjectAirFighter/FormFighterCollection.resx b/ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.resx similarity index 100% rename from ProjectAirFighter/ProjectAirFighter/FormFighterCollection.resx rename to ProjectAirFighter/ProjectAirFighter/FormWarPlaneCollection.resx diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveableFighter.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveablePlane.cs similarity index 59% rename from ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveableFighter.cs rename to ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveablePlane.cs index 249431b..70e263a 100644 --- a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveableFighter.cs +++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveablePlane.cs @@ -5,45 +5,45 @@ namespace ProjectAirFighter.MovementStrategy; /// /// Класс-реализация IMoveableObject с использованием DrawningCar /// -public class MoveableFighter : IMoveableObject +public class MoveablePlane : IMoveableObject { /// - /// Поле-объект класса DrawningFighter или его наследника + /// Поле-объект класса DrawningWarPlane или его наследника /// - private readonly DrawningFighter? _fighter = null; + private readonly DrawningWarPlane? _warPlane = null; /// /// Конструктор /// - /// - public MoveableFighter(DrawningFighter drawningFighter) + /// + 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)); } /// diff --git a/ProjectAirFighter/ProjectAirFighter/Program.cs b/ProjectAirFighter/ProjectAirFighter/Program.cs index 5734654..9361ddf 100644 --- a/ProjectAirFighter/ProjectAirFighter/Program.cs +++ b/ProjectAirFighter/ProjectAirFighter/Program.cs @@ -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()); } } } \ No newline at end of file