diff --git a/ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs b/ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs
index 04ee657..24ac509 100644
--- a/ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs
+++ b/ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs
@@ -56,7 +56,7 @@ namespace ArmoredCar
///
///
///
- public static bool operator +(MapWithSetArmoredCarsGeneric map, T car)
+ public static int operator +(MapWithSetArmoredCarsGeneric map, T car)
{
return map._setCars.Insert(car);
}
@@ -66,7 +66,7 @@ namespace ArmoredCar
///
///
///
- public static bool operator -(MapWithSetArmoredCarsGeneric map, int
+ public static T operator -(MapWithSetArmoredCarsGeneric map, int
position)
{
return map._setCars.Remove(position);
@@ -108,7 +108,7 @@ namespace ArmoredCar
public Bitmap MoveObject(Direction direction)
{
if (_map != null)
- {
+ {
return _map.MoveObject(direction);
}
return new(_pictureWidth, _pictureHeight);
@@ -149,12 +149,22 @@ namespace ArmoredCar
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
+ Brush brushRoad = new SolidBrush(Color.Gray);
+ Brush brushBox = new SolidBrush(Color.SandyBrown);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
- {
- g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i *
- _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
+ {
+ g.FillRectangle(brushRoad, i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth, _placeSizeHeight);
+ g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
+
+ int boxSize = _placeSizeWidth / 7;
+ g.FillRectangle(brushBox, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight + _placeSizeHeight / 5, boxSize, boxSize);
+ g.DrawRectangle(pen, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight + _placeSizeHeight / 5, boxSize, boxSize);
+ g.FillRectangle(brushBox, i * _placeSizeWidth + _placeSizeWidth / 2 - boxSize / 2, j * _placeSizeHeight + _placeSizeHeight / 5 + boxSize, boxSize, boxSize);
+ g.DrawRectangle(pen, i * _placeSizeWidth + _placeSizeWidth / 2 - boxSize / 2, j * _placeSizeHeight + _placeSizeHeight / 5 + boxSize, boxSize, boxSize);
+ g.FillRectangle(brushBox, i * _placeSizeWidth + _placeSizeWidth / 2 + boxSize / 2, j * _placeSizeHeight + _placeSizeHeight / 5 + boxSize, boxSize, boxSize);
+ g.DrawRectangle(pen, i * _placeSizeWidth + _placeSizeWidth / 2 + boxSize / 2, j * _placeSizeHeight + _placeSizeHeight / 5 + boxSize, boxSize, boxSize);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
(_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
@@ -169,9 +179,11 @@ namespace ArmoredCar
int width = _pictureWidth / _placeSizeWidth;
for (int i = 0; i < _setCars.Count; i++)
- {
- _setCars.Get(i)?.SetObject(i % width * _placeSizeWidth + 10, i / width * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
- _setCars.Get(i)?.DrawningObject(g);
+ {
+ if (_setCars.Get(i) != null) {
+ _setCars.Get(i)?.SetObject(i % width * _placeSizeWidth + 5, i / width * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
+ _setCars.Get(i)?.DrawningObject(g);
+ }
}
}
}
diff --git a/ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs b/ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs
index 291deed..550c07e 100644
--- a/ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs
+++ b/ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs
@@ -30,7 +30,7 @@ namespace ArmoredCar
///
/// Добавляемый автомобиль
///
- public bool Insert(T armoredCar)
+ public int Insert(T armoredCar)
{
return Insert(armoredCar, 0);
}
@@ -40,10 +40,10 @@ namespace ArmoredCar
/// Добавляемый автомобиль
/// Позиция
///
- public bool Insert(T armoredCar, int position)
+ public int Insert(T armoredCar, int position)
{
if (position < 0 || position >= Count)
- return false;
+ return -1;
if (!(_places[position] == null))
{
@@ -57,7 +57,7 @@ namespace ArmoredCar
}
}
if (index_empty == -1)
- return false;
+ return -1;
else
{
for (int i = index_empty; i > position; i--)
@@ -67,20 +67,20 @@ namespace ArmoredCar
}
}
_places[position] = armoredCar;
- return true;
+ return position;
}
///
/// Удаление объекта из набора с конкретной позиции
///
///
///
- public bool Remove(int position)
+ public T Remove(int position)
{
if (position < 0 || position >= Count)
- return false;
-
+ return null;
+ T armoredCar = _places[position];
_places[position] = null;
- return true;
+ return armoredCar;
}
///
/// Получение объекта из набора по позиции