Compare commits
No commits in common. "c4546990f8313bc8d00d46d05f7439958cd13a39" and "f6f705c9f2197d57a95d34870e79e596c73b6af4" have entirely different histories.
c4546990f8
...
f6f705c9f2
@ -1,4 +1,5 @@
|
||||
using HoistingCrane.Drawning;
|
||||
using System;
|
||||
namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
public abstract class AbstractCompany
|
||||
@ -30,7 +31,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
get
|
||||
{
|
||||
return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth)-3;
|
||||
return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth);
|
||||
}
|
||||
}
|
||||
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTrackedVehicle> array)
|
||||
@ -47,7 +48,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
}
|
||||
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
||||
{
|
||||
return company.arr?.Remove(position);
|
||||
return company.arr?.Remove(position) ?? null;
|
||||
}
|
||||
|
||||
public DrawningTrackedVehicle? GetRandomObject()
|
||||
@ -74,6 +75,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывод заднего фона
|
||||
/// </summary>
|
||||
|
@ -1,4 +1,7 @@
|
||||
using HoistingCrane.Drawning;
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
public class Garage : AbstractCompany
|
||||
@ -20,6 +23,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetObjectsPosition()
|
||||
{
|
||||
int countWidth = pictureWidth / _placeSizeWidth;
|
||||
@ -50,6 +54,5 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
namespace HoistingCrane.CollectionGenericObjects
|
||||
using System;
|
||||
namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
public interface ICollectionGenericObjects<T>
|
||||
where T: class
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
@ -25,6 +24,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
get { return list.Count; }
|
||||
}
|
||||
|
||||
public int SetMaxCount
|
||||
{
|
||||
set
|
||||
@ -38,11 +38,16 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
|
||||
public T? Get(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
if (position >= Count || position < 0) return null;
|
||||
return list[position];
|
||||
}
|
||||
|
||||
|
||||
public int Insert(T obj)
|
||||
{
|
||||
// TODO проверка, что не превышено максимальное количество элементов
|
||||
// TODO вставка в конец набора
|
||||
if (Count == _maxCount)
|
||||
{
|
||||
return -1;
|
||||
@ -53,6 +58,9 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
// TODO проверка, что не превышено максимальное количество элементов
|
||||
// TODO проверка позиции
|
||||
// TODO вставка по позиции
|
||||
if (position < 0 || position >= Count || Count == _maxCount)
|
||||
{
|
||||
return -1;
|
||||
@ -62,6 +70,8 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
}
|
||||
public T? Remove(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO удаление объекта из списка
|
||||
if (position >= 0 && position < list.Count)
|
||||
{
|
||||
T? temp = list[position];
|
||||
|
@ -45,33 +45,28 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
|
||||
if (position < 0 || position >= Count)
|
||||
//todo Проверка позиции
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int copyPos = position - 1;
|
||||
|
||||
while (position < Count)
|
||||
{
|
||||
if (arr[position] == null)
|
||||
{
|
||||
arr[position] = obj;
|
||||
return position;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
while (copyPos > 0)
|
||||
else
|
||||
{
|
||||
if (arr[copyPos] == null)
|
||||
if (Insert(obj, position + 1) != -1)
|
||||
{
|
||||
arr[copyPos] = obj;
|
||||
return copyPos;
|
||||
return position;
|
||||
}
|
||||
if (Insert(obj, position - 1) != -1)
|
||||
{
|
||||
return position;
|
||||
}
|
||||
copyPos--;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -25,12 +25,17 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
/// <param name="collectionType">тип коллекции</param>
|
||||
public void AddCollection(string name, CollectionType collectionType)
|
||||
{
|
||||
if (dict.ContainsKey(name)) return;
|
||||
if (collectionType == CollectionType.None) return;
|
||||
else if (collectionType == CollectionType.Massive)
|
||||
dict[name] = new MassivGenericObjects<T>();
|
||||
else if (collectionType == CollectionType.List)
|
||||
dict[name] = new ListGenericObjects<T>();
|
||||
if (!string.IsNullOrEmpty(name) && !Keys.Contains(name))
|
||||
{
|
||||
if(collectionType == CollectionType.Massive)
|
||||
{
|
||||
dict.Add(name, new MassivGenericObjects<T> ());
|
||||
}
|
||||
if(collectionType == CollectionType.List)
|
||||
{
|
||||
dict.Add(name, new ListGenericObjects<T> ());
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление коллекции
|
||||
@ -38,11 +43,9 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
/// <param name="name">Название коллекции</param>
|
||||
public void DelCollection(string name)
|
||||
{
|
||||
if (Keys.Contains(name))
|
||||
{
|
||||
if (dict.ContainsKey(name))
|
||||
dict.Remove(name);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к коллекции
|
||||
/// </summary>
|
||||
@ -52,11 +55,9 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
get
|
||||
{
|
||||
if (dict.ContainsKey(name))
|
||||
if (name == null || !dict.ContainsKey(name)) { return null; }
|
||||
return dict[name];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
@ -118,6 +119,7 @@
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected abstract bool IsTargetDestination();
|
||||
|
||||
/// <summary>
|
||||
/// Попытка перемещения в требуемом направлении
|
||||
/// </summary>
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace HoistingCrane.MovementStrategy
|
||||
namespace HoistingCrane.MovementStrategy
|
||||
{
|
||||
public class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
@ -14,6 +12,7 @@ namespace HoistingCrane.MovementStrategy
|
||||
|
||||
return objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
|
Loading…
Reference in New Issue
Block a user