delete ws
This commit is contained in:
parent
fb452c0f70
commit
9a97f4378d
@ -9,13 +9,11 @@ namespace ProjectCatamaran.CollectionGenericObjects;
|
||||
public abstract class AbstractCompany
|
||||
{
|
||||
protected readonly int _placeSizeWidth = 90;
|
||||
|
||||
protected readonly int _placeSizeHeight = 50;
|
||||
protected readonly int _pictureWidth;
|
||||
protected readonly int _pictureHeight;
|
||||
protected ICollectionGenericObjects<DrawningBoat?> _collection = null;
|
||||
private int GetMaxCount => (_pictureWidth / _placeSizeWidth + 1) * (_pictureHeight / _placeSizeHeight / 2) - (_pictureHeight / _placeSizeHeight / 2);
|
||||
|
||||
public AbstractCompany(int picWidth,int picHeight,ICollectionGenericObjects<DrawningBoat?> collection)
|
||||
{
|
||||
_pictureWidth = picWidth;
|
||||
@ -23,23 +21,19 @@ public abstract class AbstractCompany
|
||||
_collection = collection;
|
||||
_collection.SetMaxCount = GetMaxCount;
|
||||
}
|
||||
|
||||
public static int operator +(AbstractCompany company, DrawningBoat boat)
|
||||
{
|
||||
return company._collection?.Insert(boat) ?? -1;
|
||||
}
|
||||
|
||||
public static DrawningBoat? operator -(AbstractCompany company, int position)
|
||||
{
|
||||
return company._collection?.Remove(position);
|
||||
}
|
||||
|
||||
public DrawningBoat? GetRandomObject()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
return _collection?.Get(rnd.Next(GetMaxCount));
|
||||
}
|
||||
|
||||
public Bitmap Show()
|
||||
{
|
||||
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
|
||||
|
@ -11,7 +11,6 @@ public class Harbour : AbstractCompany
|
||||
public Harbour(int picWidth, int picHeight, ICollectionGenericObjects<DrawningBoat?> collection) : base(picWidth, picHeight, collection)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new Pen(Color.Black,2);
|
||||
@ -26,7 +25,6 @@ public class Harbour : AbstractCompany
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetObjectPosition()
|
||||
{
|
||||
int curPosX = 0;
|
||||
@ -49,7 +47,6 @@ public class Harbour : AbstractCompany
|
||||
curPosX = 0;
|
||||
curPosY++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T> where T : c
|
||||
{
|
||||
private T?[] _collection;
|
||||
public int Count => _collection.Length;
|
||||
|
||||
public int SetMaxCount
|
||||
{
|
||||
set
|
||||
@ -21,7 +20,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T> where T : c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MassiveGenericObjects()
|
||||
{
|
||||
_collection = Array.Empty<T?>();
|
||||
@ -35,7 +33,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T> where T : c
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public int Insert(T obj)
|
||||
{
|
||||
//todo
|
||||
@ -50,7 +48,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T> where T : c
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
//todo
|
||||
@ -83,7 +80,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T> where T : c
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public T? Remove(int position)
|
||||
{
|
||||
if (!(position >= 0 && position < _collection.Length) || _collection[position] == null )
|
||||
|
@ -73,7 +73,6 @@ public class DrawningBoat
|
||||
public DrawningBoat(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityBoat = new EntityBoat(speed, weight, bodyColor);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
@ -84,7 +83,6 @@ public class DrawningBoat
|
||||
{
|
||||
_drawningBoatWidth = drawningBoatWidth;
|
||||
_drawningBoatHeight = drawningBoatHeight;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// установка границ поля
|
||||
|
Loading…
x
Reference in New Issue
Block a user