Переход на конструкторы
This commit is contained in:
parent
12c4d1cbf8
commit
91aaf22ac6
@ -45,10 +45,9 @@ namespace DoubleDeckerBus
|
|||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес автобуса</param>
|
/// <param name="weight">Вес автобуса</param>
|
||||||
/// <param name="bodyColor">Цвет кузова</param>
|
/// <param name="bodyColor">Цвет кузова</param>
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public DrawningBus(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Bus = new EntityBus();
|
Bus = new EntityBus(speed, weight, bodyColor);
|
||||||
Bus.Init(speed, weight, bodyColor);
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции автобуса
|
/// Установка позиции автобуса
|
||||||
|
@ -34,7 +34,7 @@ namespace DoubleDeckerBus
|
|||||||
/// <param name="weight"></param>
|
/// <param name="weight"></param>
|
||||||
/// <param name="bodyColor"></param>
|
/// <param name="bodyColor"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public EntityBus(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||||
|
@ -24,8 +24,7 @@ namespace DoubleDeckerBus
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_bus = new DrawningBus();
|
_bus = new DrawningBus(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
_bus.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
_bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
_bus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||||
pictureBoxBus.Width, pictureBoxBus.Height);
|
pictureBoxBus.Width, pictureBoxBus.Height);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user