Завершенная laba3

This commit is contained in:
Extrimal 2023-11-01 15:35:04 +03:00
parent ce4eb04c93
commit 22f93d7571
4 changed files with 5 additions and 29 deletions

View File

@ -6,7 +6,6 @@ using System.Threading.Tasks;
using AircraftCarrier.DrawningObjects;
using AircraftCarrier.MovementStrategy;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace AircraftCarrier.Generics
{
internal class AircraftsGenericCollection<T, U>
@ -18,9 +17,9 @@ namespace AircraftCarrier.Generics
/// Высота окна прорисовки
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;
/// Конструктор
@ -33,7 +32,7 @@ namespace AircraftCarrier.Generics
_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)
{
if (obj == null)
@ -43,7 +42,7 @@ namespace AircraftCarrier.Generics
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);
if (obj != null)
@ -94,7 +93,7 @@ namespace AircraftCarrier.Generics
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);
}
}

View File

@ -5,7 +5,6 @@ using System.Text;
using System.Threading.Tasks;
using AircraftCarrier.Entities;
using AircraftCarrier.MovementStrategy;
namespace AircraftCarrier.DrawningObjects
{
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
@ -29,11 +28,7 @@ namespace AircraftCarrier.DrawningObjects
public int GetWidth => _AircraftWidth;
/// Высота объекта
public int GetHeight => _AircraftHeight;
/// Проверка, что объект может переместится по указанному направлению
/// <param name="direction">Направление</param>
/// <returns>true - можно переместится по указанному направлению</returns>
public IMoveableObject GetMoveableObject => new DrawningObjectAircraft(this);
public bool CanMove(Direction direction)
{
if (EntityAircraft == null)
@ -54,7 +49,6 @@ namespace AircraftCarrier.DrawningObjects
};
}
/// Изменение направления перемещения
/// <param name="direction">Направление</param>
public void MoveTransport(Direction direction)
{
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
width, int height)
{
@ -99,13 +88,6 @@ namespace AircraftCarrier.DrawningObjects
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
width, int height, int AircraftWidth, int AircraftHeight)
{

View File

@ -1,7 +1,6 @@
using AircraftCarrier.DrawningObjects;
using AircraftCarrier.MovementStrategy;
using System;
namespace AircraftCarrier
{
public partial class FormAircraftCarrier : Form
@ -126,7 +125,6 @@ namespace AircraftCarrier
comboBoxStrategy.Enabled = true;
_abstractStrategy = null;
}
}
private void buttonSelectAircraft_Click(object sender, EventArgs e)
{

View File

@ -20,7 +20,6 @@ namespace AircraftCarrier
InitializeComponent();
_Aircrafts = new AircraftsGenericCollection<DrawningAircraft, DrawningObjectAircraft>(PictureBoxCollection.Width, PictureBoxCollection.Height);
}
private void ButtonAddAircraft_Click(object sender, EventArgs e)
{
FormAircraftCarrier form = new();
@ -38,7 +37,6 @@ namespace AircraftCarrier
}
}
private void ButtonRemoveAircraft_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
@ -56,7 +54,6 @@ namespace AircraftCarrier
MessageBox.Show("Не удалось удалить объект");
}
}
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
PictureBoxCollection.Image = _Aircrafts.ShowAircraft();