LabWork02 PIbd-21 Zacharchenko #2

Merged
eegov merged 9 commits from LabWork02 into master 2022-10-14 08:54:17 +04:00
3 changed files with 4 additions and 9 deletions
Showing only changes of commit 6d5e7b10c0 - Show all commits

View File

@ -18,7 +18,7 @@ namespace DoubleDeckerBus
private readonly int _busWidth = 100;
private readonly int _busHeight = 50;
public void Init(int speed, float weight, Color bodyColor) {
public DrawningBus(int speed, float weight, Color bodyColor) {
Bus = new EntityBus();
Bus.Init(speed, weight, bodyColor);
}
@ -74,23 +74,20 @@ namespace DoubleDeckerBus
return;
}
Pen pen = new(Color.Black);
//границы автобсуса
g.DrawRectangle(pen, _startPosX - 1, _startPosY + 11, 100, 30);
Brush brBodyColor = new SolidBrush(Bus.BodyColor);
g.FillRectangle(brBodyColor, _startPosX, _startPosY + 10, 100, 30);
//Дверь
g.DrawRectangle(pen, _startPosX + 30, _startPosY + 20, 10, 20);
Brush brBlack = new SolidBrush(Color.Black);
g.FillRectangle(brBlack, _startPosX + 30, _startPosY + 20, 10, 20);
//Колеса
g.DrawEllipse(pen, _startPosX + 7, _startPosY + 35, 10, 10);
g.DrawEllipse(pen, _startPosX + 77, _startPosY + 35, 10, 10);
g.FillEllipse(brBlack, _startPosX + 7, _startPosY + 35, 10, 10);
g.FillEllipse(brBlack, _startPosX + 77, _startPosY + 35, 10, 10);
//окна
Brush brBlue = new SolidBrush(Color.Blue);
g.FillEllipse(brBlue, _startPosX + 10, _startPosY + 15, 10, 15);
g.FillEllipse(brBlue, _startPosX + 50, _startPosY + 15, 10, 15);

View File

@ -12,7 +12,7 @@ namespace DoubleDeckerBus
public float Weight { get; private set; }
public Color BodyColor { get; private set; }
public float Step => Speed * 100 / Weight;
public void Init(int speed, float weight, Color bodyColor)
public EntityBus(int speed, float weight, Color bodyColor)
{
Random rnd = new Random();
Speed = (speed <= 0) ? rnd.Next(50, 150) : speed;

View File

@ -19,8 +19,7 @@ namespace DoubleDeckerBus
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_bus = new DrawningBus();
_bus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_bus = new DrawningBus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxBus.Width, pictureBoxBus.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_bus.Bus.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_bus.Bus.Weight}";
@ -30,7 +29,6 @@ namespace DoubleDeckerBus
private void ButtonMove_Click(object sender, EventArgs e)
{
//ïîëó÷àåì èìÿ êíîïêè
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{