переделывание свойства доп. класса

This commit is contained in:
Мельников Игорь 2022-11-10 14:30:48 +04:00
parent f6c10b9cf0
commit 515079e770
2 changed files with 6 additions and 8 deletions

View File

@ -4,9 +4,8 @@
{ {
private WheelsNumber wheelsNumber; private WheelsNumber wheelsNumber;
public int _wheelsNumber public int WheelsNum
{ {
get => (int)wheelsNumber;
set set
{ {
if (value < 2 || value > 4) if (value < 2 || value > 4)
@ -22,24 +21,23 @@
public void DrawWheels(Graphics g, float startPosX, float startPosY, Color wheelsColor) public void DrawWheels(Graphics g, float startPosX, float startPosY, Color wheelsColor)
{ {
Pen pen = new(wheelsColor); Pen pen = new(wheelsColor);
switch (_wheelsNumber) switch (wheelsNumber)
{ {
case 2: case WheelsNumber.Two:
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
break; break;
case 3: case WheelsNumber.Three:
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15);
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
break; break;
case 4: case WheelsNumber.Four:
g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 20, startPosY + 40, 20, 15);
g.DrawEllipse(pen, startPosX + 50, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 50, startPosY + 40, 20, 15);
g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 90, startPosY + 40, 20, 15);
g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15); g.DrawEllipse(pen, startPosX + 120, startPosY + 40, 20, 15);
break; break;
} }
} }
} }

View File

@ -35,7 +35,7 @@
toolStripStatusLabelSpeed.Text = $"Скорость: {_locomotive.Locomotive.Speed}"; toolStripStatusLabelSpeed.Text = $"Скорость: {_locomotive.Locomotive.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {_locomotive.Locomotive.Weight}"; toolStripStatusLabelWeight.Text = $"Вес: {_locomotive.Locomotive.Weight}";
toolStripStatusLabelBodyColor.Text = $"Цвет: {_locomotive.Locomotive.BodyColor.Name}"; toolStripStatusLabelBodyColor.Text = $"Цвет: {_locomotive.Locomotive.BodyColor.Name}";
_locomotive.Wheels._wheelsNumber = (int)numericUpDownWheelsNumber.Value; _locomotive.Wheels.WheelsNum = (int)numericUpDownWheelsNumber.Value;
Draw(); Draw();
} }
/// <summary> /// <summary>