Завершенная laba3
This commit is contained in:
parent
ce4eb04c93
commit
22f93d7571
@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
|||||||
using AircraftCarrier.DrawningObjects;
|
using AircraftCarrier.DrawningObjects;
|
||||||
using AircraftCarrier.MovementStrategy;
|
using AircraftCarrier.MovementStrategy;
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
namespace AircraftCarrier.Generics
|
namespace AircraftCarrier.Generics
|
||||||
{
|
{
|
||||||
internal class AircraftsGenericCollection<T, U>
|
internal class AircraftsGenericCollection<T, U>
|
||||||
@ -18,9 +17,9 @@ namespace AircraftCarrier.Generics
|
|||||||
/// Высота окна прорисовки
|
/// Высота окна прорисовки
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
/// Размер занимаемого объектом места (ширина)
|
/// Размер занимаемого объектом места (ширина)
|
||||||
private readonly int _placeSizeWidth = 210;
|
private readonly int _placeSizeWidth = 170;
|
||||||
/// Размер занимаемого объектом места (высота)
|
/// Размер занимаемого объектом места (высота)
|
||||||
private readonly int _placeSizeHeight = 90;
|
private readonly int _placeSizeHeight = 50;
|
||||||
/// Набор объектов
|
/// Набор объектов
|
||||||
private readonly SetGeneric<T> _collection;
|
private readonly SetGeneric<T> _collection;
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@ -33,7 +32,7 @@ namespace AircraftCarrier.Generics
|
|||||||
_collection = new SetGeneric<T>(width * height);
|
_collection = new SetGeneric<T>(width * height);
|
||||||
}
|
}
|
||||||
/// Перегрузка оператора сложения
|
/// Перегрузка оператора сложения
|
||||||
public static int operator + (AircraftsGenericCollection<T, U> collect, T?
|
public static int operator +(AircraftsGenericCollection<T, U> collect, T?
|
||||||
obj)
|
obj)
|
||||||
{
|
{
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
@ -43,7 +42,7 @@ namespace AircraftCarrier.Generics
|
|||||||
return collect._collection.Insert(obj);
|
return collect._collection.Insert(obj);
|
||||||
}
|
}
|
||||||
/// Перегрузка оператора вычитания
|
/// Перегрузка оператора вычитания
|
||||||
public static bool operator - (AircraftsGenericCollection<T, U> collect, int pos)
|
public static bool operator -(AircraftsGenericCollection<T, U> collect, int pos)
|
||||||
{
|
{
|
||||||
T? obj = collect._collection.Get(pos);
|
T? obj = collect._collection.Get(pos);
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
@ -94,7 +93,7 @@ namespace AircraftCarrier.Generics
|
|||||||
if (aircraft != null)
|
if (aircraft != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
aircraft.SetPosition(i % inRow * _placeSizeWidth+3, (_collection.Count / inRow - 1 - i / inRow) * _placeSizeHeight+20);
|
aircraft.SetPosition(i % inRow * _placeSizeWidth+3, (_collection.Count / inRow - 1 - i / inRow) * _placeSizeHeight + 5);
|
||||||
aircraft.DrawTransport(g);
|
aircraft.DrawTransport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AircraftCarrier.Entities;
|
using AircraftCarrier.Entities;
|
||||||
using AircraftCarrier.MovementStrategy;
|
using AircraftCarrier.MovementStrategy;
|
||||||
|
|
||||||
namespace AircraftCarrier.DrawningObjects
|
namespace AircraftCarrier.DrawningObjects
|
||||||
{
|
{
|
||||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||||
@ -29,11 +28,7 @@ namespace AircraftCarrier.DrawningObjects
|
|||||||
public int GetWidth => _AircraftWidth;
|
public int GetWidth => _AircraftWidth;
|
||||||
/// Высота объекта
|
/// Высота объекта
|
||||||
public int GetHeight => _AircraftHeight;
|
public int GetHeight => _AircraftHeight;
|
||||||
/// Проверка, что объект может переместится по указанному направлению
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns>true - можно переместится по указанному направлению</returns>
|
|
||||||
public IMoveableObject GetMoveableObject => new DrawningObjectAircraft(this);
|
public IMoveableObject GetMoveableObject => new DrawningObjectAircraft(this);
|
||||||
|
|
||||||
public bool CanMove(Direction direction)
|
public bool CanMove(Direction direction)
|
||||||
{
|
{
|
||||||
if (EntityAircraft == null)
|
if (EntityAircraft == null)
|
||||||
@ -54,7 +49,6 @@ namespace AircraftCarrier.DrawningObjects
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Изменение направления перемещения
|
/// Изменение направления перемещения
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
public void MoveTransport(Direction direction)
|
public void MoveTransport(Direction direction)
|
||||||
{
|
{
|
||||||
if (!CanMove(direction) || EntityAircraft == null)
|
if (!CanMove(direction) || EntityAircraft == null)
|
||||||
@ -82,11 +76,6 @@ namespace AircraftCarrier.DrawningObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="width">Ширина картинки</param>
|
|
||||||
/// <param name="height">Высота картинки</param>
|
|
||||||
public DrawningAircraft(int speed, double weight, Color bodyColor, int
|
public DrawningAircraft(int speed, double weight, Color bodyColor, int
|
||||||
width, int height)
|
width, int height)
|
||||||
{
|
{
|
||||||
@ -99,13 +88,6 @@ namespace AircraftCarrier.DrawningObjects
|
|||||||
EntityAircraft = new EntityAircraft(speed, weight, bodyColor);
|
EntityAircraft = new EntityAircraft(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="width">Ширина картинки</param>
|
|
||||||
/// <param name="height">Высота картинки</param>
|
|
||||||
/// <param name="carWidth">Ширина прорисовки автомобиля</param>
|
|
||||||
/// <param name="carHeight">Высота прорисовки автомобиля</param>
|
|
||||||
protected DrawningAircraft(int speed, double weight, Color bodyColor,int
|
protected DrawningAircraft(int speed, double weight, Color bodyColor,int
|
||||||
width, int height, int AircraftWidth, int AircraftHeight)
|
width, int height, int AircraftWidth, int AircraftHeight)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using AircraftCarrier.DrawningObjects;
|
using AircraftCarrier.DrawningObjects;
|
||||||
using AircraftCarrier.MovementStrategy;
|
using AircraftCarrier.MovementStrategy;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace AircraftCarrier
|
namespace AircraftCarrier
|
||||||
{
|
{
|
||||||
public partial class FormAircraftCarrier : Form
|
public partial class FormAircraftCarrier : Form
|
||||||
@ -126,7 +125,6 @@ namespace AircraftCarrier
|
|||||||
comboBoxStrategy.Enabled = true;
|
comboBoxStrategy.Enabled = true;
|
||||||
_abstractStrategy = null;
|
_abstractStrategy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void buttonSelectAircraft_Click(object sender, EventArgs e)
|
private void buttonSelectAircraft_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,6 @@ namespace AircraftCarrier
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_Aircrafts = new AircraftsGenericCollection<DrawningAircraft, DrawningObjectAircraft>(PictureBoxCollection.Width, PictureBoxCollection.Height);
|
_Aircrafts = new AircraftsGenericCollection<DrawningAircraft, DrawningObjectAircraft>(PictureBoxCollection.Width, PictureBoxCollection.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddAircraft_Click(object sender, EventArgs e)
|
private void ButtonAddAircraft_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
FormAircraftCarrier form = new();
|
FormAircraftCarrier form = new();
|
||||||
@ -38,7 +37,6 @@ namespace AircraftCarrier
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRemoveAircraft_Click(object sender, EventArgs e)
|
private void ButtonRemoveAircraft_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
@ -56,7 +54,6 @@ namespace AircraftCarrier
|
|||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
PictureBoxCollection.Image = _Aircrafts.ShowAircraft();
|
PictureBoxCollection.Image = _Aircrafts.ShowAircraft();
|
||||||
|
Loading…
Reference in New Issue
Block a user