Compare commits

..

No commits in common. "ca917f05112283c9fe8a3167d39c418c47d6e857" and "d3ec22f37a296f5d0cb3cffc0ecaf977890a6f65" have entirely different histories.

4 changed files with 17 additions and 18 deletions

View File

@ -107,11 +107,11 @@ namespace Locomotive
}
Pen pen = new(Color.Black);
//тело
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Brown), _startPosX , _startPosY, 110 - 10, 50 - 10);
g.FillRectangle(new SolidBrush(Color.White), _startPosX , _startPosY, 110 - 10, 50 - 10);
//окна
g.FillRectangle(new SolidBrush(Color.Blue), _startPosX + 10, _startPosY + 10, 10, 10);
g.FillRectangle(new SolidBrush(Color.Blue), _startPosX + 30, _startPosY + 10, 10, 10);
g.FillRectangle(new SolidBrush(Color.Blue), _startPosX + 80, _startPosY + 10, 10, 10);
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 10, _startPosY + 10, 10, 10);
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 30, _startPosY + 10, 10, 10);
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 80, _startPosY + 10, 10, 10);
//дверь
g.DrawRectangle(pen, _startPosX + 50, _startPosY + 10, 10, 20);
//колеса

View File

@ -55,7 +55,7 @@ namespace Locomotive
if (form.ShowDialog() == DialogResult.OK)
{
DrawningObjectLocomotive locomotive = new(form.SelectedLocomotive);
if (_mapLocomotivesCollectionGeneric + locomotive != -1)
if (_mapLocomotivesCollectionGeneric + locomotive)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowSet();
@ -78,7 +78,7 @@ namespace Locomotive
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapLocomotivesCollectionGeneric - pos is not null)
if (_mapLocomotivesCollectionGeneric - pos)
{
MessageBox.Show("Объект удален");
pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowSet();

View File

@ -33,12 +33,12 @@ namespace Locomotive
_map = map;
}
/// Перегрузка оператора сложения
public static int operator +(MapWithSetLocomotivesGeneric<T, U> map, T locomotive)
public static bool operator +(MapWithSetLocomotivesGeneric<T, U> map, T locomotive)
{
return map._setLocomotives.Insert(locomotive);
}
/// Перегрузка оператора вычитания
public static T operator -(MapWithSetLocomotivesGeneric<T, U> map, int position)
public static bool operator -(MapWithSetLocomotivesGeneric<T, U> map, int position)
{
return map._setLocomotives.Remove(position);
}

View File

@ -19,19 +19,19 @@ namespace Locomotive
_places = new T[count];
}
/// Добавление объекта в набор
public int Insert(T locomotive)
public bool Insert(T locomotive)
{
return Insert(locomotive, 0);
}
/// Добавление объекта в набор на конкретную позицию
public int Insert(T locomotive, int position)
public bool Insert(T locomotive, int position)
{
if (position >= _places.Length|| position < 0) return -1;
if (position >= _places.Length|| position < 0) return false;
if (_places[position] == null)
{
_places[position] = locomotive;
return position;
return true;
}
int emptyEl = -1;
@ -47,7 +47,7 @@ namespace Locomotive
if (emptyEl == -1)
{
return -1;
return false;
}
for (int i = emptyEl; i > position; i--)
@ -55,15 +55,14 @@ namespace Locomotive
_places[i] = _places[i - 1];
}
_places[position] = locomotive;
return position;
return true;
}
/// Удаление объекта из набора с конкретной позиции
public T Remove(int position)
public bool Remove(int position)
{
if (position >= _places.Length || position < 0) return null;
T result = _places[position];
if (position >= _places.Length || position < 0) return false;
_places[position] = null;
return result;
return true;
}
/// Получение объекта из набора по позиции
public T Get(int position)