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

This commit is contained in:
xom9kxom9k 2024-04-14 13:46:23 +04:00
parent f69b32e6b8
commit a868c596e2
9 changed files with 67 additions and 12 deletions

View File

@ -50,7 +50,7 @@ public abstract class AbstractCompany
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
_collection.SetMaxCount = GetMaxCount;
_collection.MaxCount = GetMaxCount;
}
/// <summary>

View File

@ -20,10 +20,23 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
public int Count => _collection.Count;
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
public CollectionType GetCollectionType => CollectionType.List;
public int MaxCount
{
get
{
return Count;
}
set
{
if (value > 0)
{
_maxCount = value;
}
}
}
/// <summary>
/// Конструктор
/// </summary>

View File

@ -196,7 +196,7 @@ public class StorageCollection<T>
{
if (elem?.CreateDrawningArmoredCar() is T car)
{
if (!collection.Insert(car))
if (collection.Insert(car)== -1)
{
return false;
}

View File

@ -21,6 +21,14 @@ public class DrawningAntiAircraftGun : DrawningArmoredCar
EntityAircraftGun = new EntityAntiAircraftGun(speed, weight, bodyColor, radar, tower, additionalColor);
}
/// <summary>
/// Конструктор для Extention
/// </summary>
/// <param name="airbus"></param>
public DrawningAntiAircraftGun(EntityAntiAircraftGun armoredCar) : base(130, 60)
{
EntityAircraftGun = new EntityAntiAircraftGun(armoredCar.Speed, armoredCar.Weight, armoredCar.BodyColor, armoredCar.Radar, armoredCar.Tower, armoredCar.AdditionalColor);
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>

View File

@ -92,6 +92,14 @@ public class DrawningArmoredCar
_drawningGunHeight = drawningGunHeight;
}
/// <summary>
/// Конструктор для Extention
/// </summary>
/// <param name="airplan"></param>
public DrawningArmoredCar(EntityArmoredCar armoredCar) : this()
{
EntityAircraftGun = new EntityArmoredCar(armoredCar.Speed, armoredCar.Weight, armoredCar.BodyColor);
}
/// <summary>
/// Установка границ поля
/// </summary>
/// <param name="width"></param>

View File

@ -24,13 +24,13 @@ public static class ExtentionDrawningArmoredCar
public static DrawningArmoredCar? CreateDrawningArmoredCar(this string info)
{
string[] strs = info.Split(_separatorForObject);
DrawningArmoredCar? armoredCar = EntityAntiAircraftGun.CreateEntityAntiAircraftGun(strs);
EntityArmoredCar? armoredCar = EntityAntiAircraftGun.CreateEntityAntiAircraftGun(strs);
if (armoredCar != null)
{
return new DrawningAntiAircraftGun(armoredCar);
return new DrawningAntiAircraftGun((EntityAntiAircraftGun)armoredCar);
}
armoredCar = DrawningArmoredCar.CreateEntityArmoredCar(strs);
armoredCar = EntityArmoredCar.CreateEntityArmoredCar(strs);
if (armoredCar != null)
{
return new DrawningArmoredCar(armoredCar);

View File

@ -1,4 +1,6 @@
namespace AntiAircraftGun.Entities;
using AntiAircraftGun.Drawnings;
namespace AntiAircraftGun.Entities;
/// <summary>
/// Класс-сущность Зенитная установка
/// </summary>
@ -40,4 +42,28 @@ public class EntityAntiAircraftGun : EntityArmoredCar
Tower = tower;
AdditionalColor = additionalColor;
}
/// <summary>
/// Получение строк со значениями свойств продвинутого объекта класса-сущности
/// </summary>
/// <returns></returns>
public override string[] GetStringRepresentation()
{
return new[] { nameof(EntityAntiAircraftGun), Speed.ToString(), Weight.ToString(), BodyColor.Name, Tower.ToString(), Radar.ToString(), AdditionalColor.Name};
}
/// <summary>
/// Создание продвинутого объекта из массива строк
/// </summary>
/// <param name="strs"></param>
/// <returns></returns>
public static EntityAntiAircraftGun? CreateEntityAntiAircraftGun(string[] strs)
{
if (strs.Length != 7 || strs[0] != nameof(EntityAntiAircraftGun))
{
return null;
}
return new EntityAntiAircraftGun(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]),
Convert.ToBoolean(strs[5]),Color.FromName(strs[6]));
}
}

View File

@ -55,7 +55,7 @@ public class EntityArmoredCar
/// </summary>
/// <param name="strs"></param>
/// <returns></returns>
public static EntityArmoredCar? CreateEntityTrackedCar(string[] strs)
public static EntityArmoredCar? CreateEntityArmoredCar(string[] strs)
{
if (strs.Length != 4 || strs[0] != nameof(EntityArmoredCar))
{

View File

@ -68,7 +68,7 @@
groupBoxToools.Dock = DockStyle.Right;
groupBoxToools.Location = new Point(1057, 24);
groupBoxToools.Name = "groupBoxToools";
groupBoxToools.Size = new Size(210, 591);
groupBoxToools.Size = new Size(210, 612);
groupBoxToools.TabIndex = 0;
groupBoxToools.TabStop = false;
groupBoxToools.Text = "Инструменты";
@ -248,7 +248,7 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 24);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(1057, 591);
pictureBox.Size = new Size(1057, 612);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
@ -296,7 +296,7 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1267, 615);
ClientSize = new Size(1267, 636);
Controls.Add(pictureBox);
Controls.Add(groupBoxToools);
Controls.Add(menuStrip);