Lab_work02 #2

Merged
eegov merged 5 commits from Lab_work02 into Lab_work)1 2022-10-14 09:51:31 +04:00
3 changed files with 4 additions and 6 deletions
Showing only changes of commit f6797078a8 - Show all commits

View File

@ -16,10 +16,9 @@ namespace Bus
protected readonly int _busWidth = 157;
protected readonly int _busHeight = 65;
public void Init(int speed, float weight, Color bodyColor)
public DrawingBus(int speed, float weight, Color bodyColor)
{
Bus = new EntityBus();
Bus.Init(speed, weight, bodyColor);
Bus = new EntityBus(speed, weight, bodyColor);
}
public void SetPosition(int x, int y, int width, int height)

View File

@ -13,7 +13,7 @@ namespace Bus
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

@ -21,8 +21,7 @@ namespace Bus
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_bus = new DrawingBus();
_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 DrawingBus(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}";