diff --git a/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs
index 960fe8b..6d8f6ae 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/DrawingDoubleDeckerBus.cs
@@ -18,10 +18,10 @@ public class DrawingDoubleDeckerBus
private readonly int _DrawingBusHight = 60;
- public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool sideMirrors, bool topSection, bool stripes, bool stairs)
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor,bool secondFloor, bool stripes)
{
EntityDoubleDeckerBus = new EntityDoubleDeckerBus();
- EntityDoubleDeckerBus.Init(speed, weight, bodyColor, additionalColor, sideMirrors, topSection, stripes, stairs);
+ EntityDoubleDeckerBus.Init(speed, weight, bodyColor, additionalColor, secondFloor, stripes);
_pictureWidth = null;
_pictureHeight = null;
_startPosX = null;
@@ -144,32 +144,20 @@ public class DrawingDoubleDeckerBus
return;
}
- Pen pen = new(Color.Black, 2);
+ Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(EntityDoubleDeckerBus.AdditionalColor);
Brush mainBrush = new SolidBrush(EntityDoubleDeckerBus.BodyColor);
+ Brush blueBr = new SolidBrush(Color.LightBlue);
- //зеркала
- if (EntityDoubleDeckerBus.SideMirrors)
- {
- g.DrawRectangle(pen, _startPosX.Value + 95, _startPosY.Value + 5, 20, 5);
- g.DrawRectangle(pen, _startPosX.Value + 110, _startPosY.Value + 10, 5, 5);
- g.FillRectangle(mainBrush, _startPosX.Value + 95, _startPosY.Value + 5, 20, 5);
- g.FillRectangle(additionalBrush, _startPosX.Value + 110, _startPosY.Value + 10, 5, 5);
-
- }
-
- //кузов
- PointF[] bus = { new PointF((float)_startPosX + 5, (float)_startPosY + 5), new PointF((float)_startPosX + 5, (float)_startPosY + 45), new PointF((float)_startPosX + 105, (float)_startPosY + 45), new PointF((float)_startPosX + 105, (float)_startPosY + 25), new PointF((float)_startPosX + 95, (float)_startPosY + 5) };
- g.DrawPolygon(pen, bus);
+
+ //кузов 1го этажа
+ PointF[] bus = { new PointF((float)_startPosX + 5, (float)_startPosY + 20),
+ new PointF((float)_startPosX + 5, (float)_startPosY + 45),
+ new PointF((float)_startPosX + 105, (float)_startPosY + 45),
+ new PointF((float)_startPosX + 105, (float)_startPosY + 25),
+ new PointF((float)_startPosX + 102, (float)_startPosY + 20) };
g.FillPolygon(mainBrush, bus);
-
- //вехний отсек
- if (EntityDoubleDeckerBus.TopSection)
- {
- PointF[] section = { new PointF((float)_startPosX + 27, (float)_startPosY + 5), new PointF((float)_startPosX + 37, (float)_startPosY + 1), new PointF((float)_startPosX + 65, (float)_startPosY + 1), new PointF((float)_startPosX + 75, (float)_startPosY + 5) };
- g.DrawPolygon(pen, section);
- g.FillPolygon(additionalBrush, section);
- }
+ g.DrawPolygon(pen, bus);
//полоски
if (EntityDoubleDeckerBus.Stripes)
@@ -179,63 +167,95 @@ public class DrawingDoubleDeckerBus
g.FillPolygon(additionalBrush, stripe);
}
- //окна 2ой этаж
- Brush blueBr = new SolidBrush(Color.LightBlue);
- g.DrawRectangle(pen, _startPosX.Value + 7, _startPosY.Value + 10, 12, 10);
- g.DrawRectangle(pen, _startPosX.Value + 21, _startPosY.Value + 10, 12, 10);
- g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 10, 10, 10);
- g.DrawRectangle(pen, _startPosX.Value + 47, _startPosY.Value + 10, 6, 10);
- g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 10, 13, 10);
- g.DrawRectangle(pen, _startPosX.Value + 71, _startPosY.Value + 10, 14, 10);
-
- g.FillRectangle(blueBr, _startPosX.Value + 7, _startPosY.Value + 10, 12, 10);
- g.FillRectangle(blueBr, _startPosX.Value + 21, _startPosY.Value + 10, 12, 10);
- g.FillRectangle(blueBr, _startPosX.Value + 35, _startPosY.Value + 10, 10, 10);
- g.FillRectangle(blueBr, _startPosX.Value + 47, _startPosY.Value + 10, 6, 10);
- g.FillRectangle(blueBr, _startPosX.Value + 55, _startPosY.Value + 10, 13, 10);
- g.FillRectangle(blueBr, _startPosX.Value + 71, _startPosY.Value + 10, 14, 10);
-
+
//окна 1ый этаж
- g.DrawRectangle(pen, _startPosX.Value + 7, _startPosY.Value + 25, 12, 10);
- g.DrawRectangle(pen, _startPosX.Value + 21, _startPosY.Value + 25, 12, 10);
- g.DrawRectangle(pen, _startPosX.Value + 47, _startPosY.Value + 25, 6, 10);
- g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 25, 13, 10);
- g.DrawRectangle(pen, _startPosX.Value + 71, _startPosY.Value + 25, 14, 10);
-
g.FillRectangle(blueBr, _startPosX.Value + 7, _startPosY.Value + 25, 12, 10);
g.FillRectangle(blueBr, _startPosX.Value + 21, _startPosY.Value + 25, 12, 10);
g.FillRectangle(blueBr, _startPosX.Value + 47, _startPosY.Value + 25, 6, 10);
g.FillRectangle(blueBr, _startPosX.Value + 55, _startPosY.Value + 25, 13, 10);
g.FillRectangle(blueBr, _startPosX.Value + 71, _startPosY.Value + 25, 14, 10);
- //два передних окна
- PointF[] window1 = { new PointF((float)_startPosX + 90, (float)_startPosY + 10), new PointF((float)_startPosX + 97, (float)_startPosY + 10), new PointF((float)_startPosX + 102, (float)_startPosY + 20), new PointF((float)_startPosX + 90, (float)_startPosY + 20) };
- PointF[] window2 = { new PointF((float)_startPosX + 90, (float)_startPosY + 25), new PointF((float)_startPosX + 105, (float)_startPosY + 25), new PointF((float)_startPosX + 105, (float)_startPosY + 40), new PointF((float)_startPosX + 90, (float)_startPosY + 35) };
- g.DrawPolygon(pen, window1);
- g.DrawPolygon(pen, window2);
- g.FillPolygon(blueBr, window1);
+ g.DrawRectangle(pen, _startPosX.Value + 7, _startPosY.Value + 25, 12, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 21, _startPosY.Value + 25, 12, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 47, _startPosY.Value + 25, 6, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 25, 13, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 71, _startPosY.Value + 25, 14, 10);
+
+ //переднее окно первый этаж
+ PointF[] window2 = { new PointF((float)_startPosX + 90, (float)_startPosY + 25),
+ new PointF((float)_startPosX + 105, (float)_startPosY + 25),
+ new PointF((float)_startPosX + 105, (float)_startPosY + 40),
+ new PointF((float)_startPosX + 90, (float)_startPosY + 35) };
g.FillPolygon(blueBr, window2);
+ g.DrawPolygon(pen, window2);
//дверь
Brush brownBr = new SolidBrush(Color.Brown);
- g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 25, 10, 15);
- g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 40, 10, 5);
-
g.FillRectangle(blueBr, _startPosX.Value + 35, _startPosY.Value + 25, 10, 15);
g.FillRectangle(brownBr, _startPosX.Value + 35, _startPosY.Value + 40, 10, 5);
+ g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 25, 10, 15);
+ g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 40, 10, 5);
//колёса
- g.DrawEllipse(pen, _startPosX.Value + 11, _startPosY.Value + 37, 16, 16);
- g.DrawEllipse(pen, _startPosX.Value + 83, _startPosY.Value + 37, 16, 16);
g.FillEllipse(brownBr, _startPosX.Value + 11, _startPosY.Value + 37, 16, 16);
g.FillEllipse(brownBr, _startPosX.Value + 83, _startPosY.Value + 37, 16, 16);
- //лестница
- if (EntityDoubleDeckerBus.Stairs)
- {
- g.DrawLine(pen, new Point(_startPosX.Value + 1, _startPosY.Value + 45), new Point(_startPosX.Value + 1, _startPosY.Value + 3));
+ g.DrawEllipse(pen, _startPosX.Value + 11, _startPosY.Value + 37, 16, 16);
+ g.DrawEllipse(pen, _startPosX.Value + 83, _startPosY.Value + 37, 16, 16);
+ //второй этаж с всякими зафуфрючками
+ if (EntityDoubleDeckerBus.SecondFloor)
+ {
+ //верх кузова
+ PointF[] bus_second_floor = { new PointF((float)_startPosX + 5, (float)_startPosY + 5),
+ new PointF((float)_startPosX + 5, (float)_startPosY + 20),
+ new PointF((float)_startPosX + 102, (float)_startPosY + 20),
+ new PointF((float)_startPosX + 95, (float)_startPosY + 5)};
+ g.FillPolygon(mainBrush, bus_second_floor);
+ g.DrawPolygon(pen, bus_second_floor);
+
+ //окна 2ой этаж
+
+ g.FillRectangle(blueBr, _startPosX.Value + 7, _startPosY.Value + 10, 12, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 21, _startPosY.Value + 10, 12, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 35, _startPosY.Value + 10, 10, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 47, _startPosY.Value + 10, 6, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 55, _startPosY.Value + 10, 13, 10);
+ g.FillRectangle(blueBr, _startPosX.Value + 71, _startPosY.Value + 10, 14, 10);
+
+ g.DrawRectangle(pen, _startPosX.Value + 7, _startPosY.Value + 10, 12, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 21, _startPosY.Value + 10, 12, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 10, 10, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 47, _startPosY.Value + 10, 6, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 10, 13, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 71, _startPosY.Value + 10, 14, 10);
+
+ //верхний отсек
+ PointF[] section = { new PointF((float)_startPosX + 27, (float)_startPosY + 5),
+ new PointF((float)_startPosX + 37, (float)_startPosY + 1),
+ new PointF((float)_startPosX + 65, (float)_startPosY + 1),
+ new PointF((float)_startPosX + 75, (float)_startPosY + 5) };
+ g.FillPolygon(additionalBrush, section);
+ g.DrawPolygon(pen, section);
+
+ //переднее окно 2ой этаж
+ PointF[] window1 = { new PointF((float)_startPosX + 90, (float)_startPosY + 10),
+ new PointF((float)_startPosX + 97, (float)_startPosY + 10),
+ new PointF((float)_startPosX + 102, (float)_startPosY + 20),
+ new PointF((float)_startPosX + 90, (float)_startPosY + 20) };
+ g.FillPolygon(blueBr, window1);
+ g.DrawPolygon(pen, window1);
+
+ //зеркала
+ g.FillRectangle(mainBrush, _startPosX.Value + 95, _startPosY.Value + 5, 20, 5);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 110, _startPosY.Value + 10, 5, 5);
+
+ g.DrawRectangle(pen, _startPosX.Value + 95, _startPosY.Value + 5, 20, 5);
+ g.DrawRectangle(pen, _startPosX.Value + 110, _startPosY.Value + 10, 5, 5);
+
+ //лестница
+ g.DrawLine(pen, new Point(_startPosX.Value + 1, _startPosY.Value + 45), new Point(_startPosX.Value + 1, _startPosY.Value + 3));
g.DrawLine(pen, new Point(_startPosX.Value + 1, _startPosY.Value + 45), new Point(_startPosX.Value + 5, _startPosY.Value + 43));
g.DrawLine(pen, new Point(_startPosX.Value + 1, _startPosY.Value + 39), new Point(_startPosX.Value + 5, _startPosY.Value + 37));
g.DrawLine(pen, new Point(_startPosX.Value + 1, _startPosY.Value + 31), new Point(_startPosX.Value + 5, _startPosY.Value + 29));
diff --git a/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
index 16150eb..bdfa702 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/EntityDoubleDeckerBus.cs
@@ -13,22 +13,14 @@
///
public Color AdditionalColor { get; private set; }
///
- /// Признак (опция) наличия боковых зеркал
+ /// Признак (опция) наличия второго этажа
///
- public bool SideMirrors { get; private set; }
- ///
- /// Признак (опция) наличия верхней панели
- ///
- public bool TopSection { get; private set; }
+ public bool SecondFloor { get; private set; }
///
/// Признак (опция) наличия полосок на автобусе
///
public bool Stripes { get; private set; }
///
- /// Признак (опция) наличия лестницы
- ///
- public bool Stairs { get; private set; }
- ///
/// Шаг перемещения автобуса
///
public double Step => Speed * 100 / Weight;
@@ -42,15 +34,13 @@
///
///
///
- public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool sideMirrors, bool topSection, bool stripes, bool stairs)
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool secondFloor, bool stripes)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
- SideMirrors = sideMirrors;
- TopSection = topSection;
+ SecondFloor = secondFloor;
Stripes = stripes;
- Stairs = stairs;
}
}
\ No newline at end of file
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs
index 49c6356..e44a6c5 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormDoubleDeckerBus.cs
@@ -38,7 +38,7 @@ namespace DoubleDeckerBus
_drawingDoubleDeckerBus.Init(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_drawingDoubleDeckerBus.SetPictureSize(pictureBoxDoubleDeckerBus.Width, pictureBoxDoubleDeckerBus.Height);
_drawingDoubleDeckerBus.SetPosition(random.Next(10, 100), random.Next(10, 100));