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