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

This commit is contained in:
nezui1 2024-04-06 13:40:17 +03:00
parent 26e0d00ce5
commit f74d8a8bd3
6 changed files with 31 additions and 15 deletions

View File

@ -0,0 +1,16 @@
using ProjectAirFighter.Drawning;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAirFighter;
public class AdNum<T>
where T : DrawningAirFighter
{
public void Nothing(){
}
}

View File

@ -32,7 +32,7 @@ public abstract class AbstractCompany
/// <summary> /// <summary>
/// Коллекция военных самолетов /// Коллекция военных самолетов
/// </summary> /// </summary>
protected ICollectionGeneticObjects<DrawningWarPlane> _collection = null; protected ICollectionGenericObjects<DrawningWarPlane> _collection = null;
/// <summary> /// <summary>
/// Вычисление максимального количества элементов, которые можно разместить в окне /// Вычисление максимального количества элементов, которые можно разместить в окне
@ -45,12 +45,12 @@ public abstract class AbstractCompany
/// <param name="picWidth">Ширина окна</param> /// <param name="picWidth">Ширина окна</param>
/// <param name="picHeight">Высота окна</param> /// <param name="picHeight">Высота окна</param>
/// <param name="collection">Коллекция военных самолетов</param> /// <param name="collection">Коллекция военных самолетов</param>
public AbstractCompany(int picWidth, int picHeight, ICollectionGeneticObjects<DrawningWarPlane> collection) public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningWarPlane> collection)
{ {
_pictureWidth = picWidth; _pictureWidth = picWidth;
_pictureHeight = picHeight; _pictureHeight = picHeight;
_collection = collection; _collection = collection;
_collection.SetMaxCount = GetMaxCount; _collection.SetMaxCount = GetMaxCount - 4;
} }
/// <summary> /// <summary>

View File

@ -10,7 +10,7 @@ namespace ProjectAirFighter.CollectionGenericObject;
/// Интерфейс описания действий для набора хранимых объектов /// Интерфейс описания действий для набора хранимых объектов
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public interface ICollectionGeneticObjects<T> public interface ICollectionGenericObjects<T>
where T : class where T : class
{ {
/// <summary> /// <summary>

View File

@ -1,4 +1,5 @@
using ProjectAirFighter.CollectionGenericObject; using ProjectAirFighter.CollectionGenericObject;
using ProjectAirFighter.CollectionGenericObjects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -10,7 +11,7 @@ namespace ProjectAirFighter.CollectionGenericObjects;
/// Параметризованный набор объектов /// Параметризованный набор объектов
/// </summary> /// </summary>
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam> /// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
public class MassiveGenericObjects<T> : ICollectionGeneticObjects<T> public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
where T : class where T : class
{ {
/// <summary> /// <summary>

View File

@ -10,7 +10,7 @@ namespace ProjectAirFighter.CollectionGenericObjects;
public class WarPlaneBase : AbstractCompany public class WarPlaneBase : AbstractCompany
{ {
public WarPlaneBase(int picWidth, int picHeight, ICollectionGeneticObjects<DrawningWarPlane> collection) : base(picWidth, picHeight, collection) public WarPlaneBase(int picWidth, int picHeight, ICollectionGenericObjects<DrawningWarPlane> collection) : base(picWidth, picHeight, collection)
{ {
} }
@ -32,8 +32,8 @@ public class WarPlaneBase : AbstractCompany
int width = _pictureWidth / _placeSizeWidth; int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight; int height = _pictureHeight / _placeSizeHeight;
int curWidth = 0; int curWidth = width - 1;
int curHeight = 0; int curHeight = height - 1;
for (int i = 0; i < (_collection?.Count ?? 0); i++) for (int i = 0; i < (_collection?.Count ?? 0); i++)
{ {
@ -43,14 +43,14 @@ public class WarPlaneBase : AbstractCompany
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight + 5); _collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight + 5);
} }
if (curHeight < height - 1) if (curWidth > 0)
curHeight++; curWidth--;
else else
{ {
curHeight = 0; curHeight--;
curWidth++; curWidth = width - 1;
} }
if (curHeight > height) if (curHeight < 0)
{ {
return; return;

View File

@ -45,8 +45,7 @@ public partial class FormWarPlaneCollection : Form
break; break;
case nameof(DrawningAirFighter): case nameof(DrawningAirFighter):
drawningWarPlane = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000), drawningWarPlane = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), GetColor(random), GetColor(random),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break; break;
default: default: