Лаба 3, которая готовая.
This commit is contained in:
parent
614075b569
commit
34d5daf3b1
@ -31,7 +31,7 @@ public class Garage : AbstractCompany
|
||||
{
|
||||
int cntVertically = _pictureHeight / _placeSizeHeight; //Колличество мест по вертикали
|
||||
int cntHorizontally = _pictureWidth / _placeSizeWidth; //Колличество мест по горизонтали
|
||||
Pen pen = new Pen(Color.FromArgb(0, 0, 0));
|
||||
Pen pen = new Pen(Color.FromArgb(185, 140, 0));
|
||||
pen.Width = 3;
|
||||
|
||||
for (int i = 0; i < cntHorizontally; i++)
|
||||
|
@ -35,7 +35,7 @@ public class DrawningBulldozer : DrawningDozer
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
|
||||
Brush additionalBrush = new SolidBrush(EntityDozer.AdditionalColor);
|
||||
Brush additionalBrush = new SolidBrush(bulldozer.AdditionalColor);
|
||||
//BULDOZER
|
||||
_startPosX += 0;
|
||||
_startPosY += 0;
|
||||
|
@ -86,9 +86,9 @@ public class DrawningDozer
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет(цвет колёс)</param>
|
||||
public DrawningDozer(int speed, double weight, Color bodyColor, Color additionalColor) : this()
|
||||
public DrawningDozer(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityDozer = new EntityDozer(speed, weight, bodyColor, additionalColor);
|
||||
EntityDozer = new EntityDozer(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -99,9 +99,7 @@ public class DrawningDozer
|
||||
protected DrawningDozer (int drawningBulldozerWidth, int drawningBulldozerHeigh) :this()
|
||||
{
|
||||
_drawningBulldozerWidth = drawningBulldozerWidth;
|
||||
//????????
|
||||
_pictureHeight = drawningBulldozerHeigh;
|
||||
//????????
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@ -245,19 +243,19 @@ public class DrawningDozer
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
|
||||
Brush additionalBrush = new SolidBrush(EntityDozer.AdditionalColor);
|
||||
Brush wheelsBrush = new SolidBrush(Color.FromArgb(60, 60, 60));
|
||||
//BULDOZER
|
||||
//body
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30);
|
||||
//wheels
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.FillRectangle(wheelsBrush, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.FillRectangle(wheelsBrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 50, 15);
|
||||
g.FillRectangle(wheelsBrush, _startPosX.Value, _startPosY.Value, 50, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 50, 15);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
|
||||
g.FillRectangle(wheelsBrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
|
||||
//strange rectangles
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 25, 3, _drawningBulldozerHeight - 50);
|
||||
|
@ -22,28 +22,25 @@ public class EntityBulldozer : EntityDozer
|
||||
/// Признак (опция) наличие гусеницы
|
||||
/// </summary>
|
||||
public bool Caterpillar { get; private set; }
|
||||
/*
|
||||
|
||||
|
||||
///<summary>
|
||||
/// Шаг перемещения бульдозера
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;*/
|
||||
/*
|
||||
///<summary>
|
||||
///Инициализация полей объекта-класса бульдозера
|
||||
/// </summary>
|
||||
///<param name="speed">Скорость</param>
|
||||
///<param name="weight">Вес</param>
|
||||
///<param name="bodyColor">Основной цвет</param>
|
||||
///<param name="additionalColor">Дополнительный цвет</param>
|
||||
///<param name="blade">Признак наличия отвала</param>
|
||||
///<param name="caterpillar">Признак наличия гусеницы</param>
|
||||
public void EntityBulldozer(bool blade, bool caterpillar) base(speed, )
|
||||
{
|
||||
Blade = blade;
|
||||
Caterpillar = caterpillar;
|
||||
}*/
|
||||
public EntityBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool caterpillar) : base(speed, weight, bodyColor, additionalColor)
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
///<summary>
|
||||
///Инициализация полей объекта-класса бульдозера
|
||||
/// </summary>
|
||||
///<param name="speed">Скорость</param>
|
||||
///<param name="weight">Вес</param>
|
||||
///<param name="bodyColor">Основной цвет</param>
|
||||
///<param name="additionalColor">Дополнительный цвет</param>
|
||||
///<param name="blade">Признак наличия отвала</param>
|
||||
///<param name="caterpillar">Признак наличия гусеницы</param>
|
||||
public EntityBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool caterpillar) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
Blade = blade;
|
||||
Caterpillar = caterpillar;
|
||||
}
|
||||
|
@ -26,11 +26,6 @@ public class EntityDozer
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
///<summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
///<summary>
|
||||
/// Шаг перемещения бульдозера
|
||||
/// </summary>
|
||||
@ -42,13 +37,11 @@ public class EntityDozer
|
||||
///<param name="speed">Скорость</param>
|
||||
///<param name="weight">Вес</param>
|
||||
///<param name="bodyColor">Основной цвет</param>
|
||||
///<param name="additionalColor">Дополнительный цвет</param>
|
||||
public EntityDozer(int speed, double weight, Color bodyColor, Color additionalColor)
|
||||
public EntityDozer(int speed, double weight, Color bodyColor/*, Color additionalColor*/)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -89,14 +89,13 @@ public partial class FormBulldozerCollection : Form
|
||||
{
|
||||
case nameof(DrawningDozer):
|
||||
drawningDozer = new DrawningDozer(random.Next(100, 300), random.Next(1000, 3000),
|
||||
GetBodyColor(random), Color.FromArgb(random.Next(30, 120), random.Next(30, 120), random.Next(30, 120)));
|
||||
GetBodyColor(random));
|
||||
break;
|
||||
case nameof(DrawningBulldozer):
|
||||
//TODO вызов диалогового окна для выбора цвета
|
||||
//Вызов диалогового окна для выбора цвета
|
||||
drawningDozer = new DrawningBulldozer(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(170, 256), random.Next(170, 256), random.Next(30, 140)),
|
||||
Color.FromArgb(random.Next(30, 120), random.Next(30, 120), random.Next(30, 120)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
GetBodyColor(random), GetWheelsColor(random),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@ -114,7 +113,7 @@ public partial class FormBulldozerCollection : Form
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение цвета самого бульдозера
|
||||
/// Получение цвета корпуса бульдозера
|
||||
/// </summary>
|
||||
/// <param name="random">Генератор случайных чисел</param>
|
||||
/// <returns></returns>
|
||||
@ -129,6 +128,22 @@ public partial class FormBulldozerCollection : Form
|
||||
return color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение цвета гусеницы бульдозера
|
||||
/// </summary>
|
||||
/// <param name="random">Генератор случайных чисел</param>
|
||||
/// <returns></returns>
|
||||
private static Color GetWheelsColor(Random random)
|
||||
{
|
||||
Color color = Color.FromArgb(random.Next(30, 120), random.Next(30, 120), random.Next(30, 120));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user