Lab_work02 #2
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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}";
|
||||
|
Loading…
Reference in New Issue
Block a user