Лабораторная работа№3
This commit is contained in:
parent
26e0d00ce5
commit
f74d8a8bd3
16
ProjectAirFighter/ProjectAirFighter/AdNum.cs
Normal file
16
ProjectAirFighter/ProjectAirFighter/AdNum.cs
Normal 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(){
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public abstract class AbstractCompany
|
||||
/// <summary>
|
||||
/// Коллекция военных самолетов
|
||||
/// </summary>
|
||||
protected ICollectionGeneticObjects<DrawningWarPlane> _collection = null;
|
||||
protected ICollectionGenericObjects<DrawningWarPlane> _collection = null;
|
||||
|
||||
/// <summary>
|
||||
/// Вычисление максимального количества элементов, которые можно разместить в окне
|
||||
@ -45,12 +45,12 @@ public abstract class AbstractCompany
|
||||
/// <param name="picWidth">Ширина окна</param>
|
||||
/// <param name="picHeight">Высота окна</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;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = collection;
|
||||
_collection.SetMaxCount = GetMaxCount;
|
||||
_collection.SetMaxCount = GetMaxCount - 4;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -10,7 +10,7 @@ namespace ProjectAirFighter.CollectionGenericObject;
|
||||
/// Интерфейс описания действий для набора хранимых объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public interface ICollectionGeneticObjects<T>
|
||||
public interface ICollectionGenericObjects<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
@ -1,4 +1,5 @@
|
||||
using ProjectAirFighter.CollectionGenericObject;
|
||||
using ProjectAirFighter.CollectionGenericObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,7 +11,7 @@ namespace ProjectAirFighter.CollectionGenericObjects;
|
||||
/// Параметризованный набор объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
||||
public class MassiveGenericObjects<T> : ICollectionGeneticObjects<T>
|
||||
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -10,7 +10,7 @@ namespace ProjectAirFighter.CollectionGenericObjects;
|
||||
|
||||
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 height = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
int curWidth = 0;
|
||||
int curHeight = 0;
|
||||
int curWidth = width - 1;
|
||||
int curHeight = height - 1;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (curHeight < height - 1)
|
||||
curHeight++;
|
||||
if (curWidth > 0)
|
||||
curWidth--;
|
||||
else
|
||||
{
|
||||
curHeight = 0;
|
||||
curWidth++;
|
||||
curHeight--;
|
||||
curWidth = width - 1;
|
||||
}
|
||||
if (curHeight > height)
|
||||
if (curHeight < 0)
|
||||
{
|
||||
return;
|
||||
|
||||
|
@ -45,8 +45,7 @@ public partial class FormWarPlaneCollection : Form
|
||||
break;
|
||||
case nameof(DrawningAirFighter):
|
||||
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)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
GetColor(random), GetColor(random),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user