Compare commits
2 Commits
d3ec22f37a
...
ca917f0511
Author | SHA1 | Date | |
---|---|---|---|
ca917f0511 | |||
e1b431152b |
@ -107,11 +107,11 @@ namespace Locomotive
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
//тело
|
||||
g.FillRectangle(new SolidBrush(Color.White), _startPosX , _startPosY, 110 - 10, 50 - 10);
|
||||
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Brown), _startPosX , _startPosY, 110 - 10, 50 - 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.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.DrawRectangle(pen, _startPosX + 50, _startPosY + 10, 10, 20);
|
||||
//колеса
|
||||
|
@ -55,7 +55,7 @@ namespace Locomotive
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectLocomotive locomotive = new(form.SelectedLocomotive);
|
||||
if (_mapLocomotivesCollectionGeneric + locomotive)
|
||||
if (_mapLocomotivesCollectionGeneric + locomotive != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowSet();
|
||||
@ -78,7 +78,7 @@ namespace Locomotive
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapLocomotivesCollectionGeneric - pos)
|
||||
if (_mapLocomotivesCollectionGeneric - pos is not null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapLocomotivesCollectionGeneric.ShowSet();
|
||||
|
@ -33,12 +33,12 @@ namespace Locomotive
|
||||
_map = map;
|
||||
}
|
||||
/// Перегрузка оператора сложения
|
||||
public static bool operator +(MapWithSetLocomotivesGeneric<T, U> map, T locomotive)
|
||||
public static int operator +(MapWithSetLocomotivesGeneric<T, U> map, T locomotive)
|
||||
{
|
||||
return map._setLocomotives.Insert(locomotive);
|
||||
}
|
||||
/// Перегрузка оператора вычитания
|
||||
public static bool operator -(MapWithSetLocomotivesGeneric<T, U> map, int position)
|
||||
public static T operator -(MapWithSetLocomotivesGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setLocomotives.Remove(position);
|
||||
}
|
||||
|
@ -19,19 +19,19 @@ namespace Locomotive
|
||||
_places = new T[count];
|
||||
}
|
||||
/// Добавление объекта в набор
|
||||
public bool Insert(T locomotive)
|
||||
public int Insert(T locomotive)
|
||||
{
|
||||
return Insert(locomotive, 0);
|
||||
}
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
public bool Insert(T locomotive, int position)
|
||||
public int Insert(T locomotive, int position)
|
||||
{
|
||||
if (position >= _places.Length|| position < 0) return false;
|
||||
if (position >= _places.Length|| position < 0) return -1;
|
||||
|
||||
if (_places[position] == null)
|
||||
{
|
||||
_places[position] = locomotive;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
|
||||
int emptyEl = -1;
|
||||
@ -47,7 +47,7 @@ namespace Locomotive
|
||||
|
||||
if (emptyEl == -1)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = emptyEl; i > position; i--)
|
||||
@ -55,14 +55,15 @@ namespace Locomotive
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
_places[position] = locomotive;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
public bool Remove(int position)
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position >= _places.Length || position < 0) return false;
|
||||
if (position >= _places.Length || position < 0) return null;
|
||||
T result = _places[position];
|
||||
_places[position] = null;
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
/// Получение объекта из набора по позиции
|
||||
public T Get(int position)
|
||||
|
Loading…
Reference in New Issue
Block a user