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); 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(Locomotive?.BodyColor ?? Color.Black), _startPosX + 10, _startPosY + 10, 10, 10);
g.FillRectangle(new SolidBrush(Color.Blue), _startPosX + 30, _startPosY + 10, 10, 10); g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _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 + 80, _startPosY + 10, 10, 10);
//дверь //дверь
g.DrawRectangle(pen, _startPosX + 50, _startPosY + 10, 10, 20); g.DrawRectangle(pen, _startPosX + 50, _startPosY + 10, 10, 20);
//колеса //колеса

View File

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

View File

@ -33,12 +33,12 @@ namespace Locomotive
_map = map; _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); 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); return map._setLocomotives.Remove(position);
} }

View File

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