Переход на конструкторы
This commit is contained in:
parent
53d1bef6d8
commit
6b21c79439
@ -45,10 +45,9 @@ namespace Boats
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес лодки</param>
|
||||
/// <param name="bodyColor">Цвет корпуса</param>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public DrawingBoat(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Boat = new EntityBoat();
|
||||
Boat.Init(speed, weight, bodyColor);
|
||||
Boat = new EntityBoat(speed, weight, bodyColor);
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции лодки
|
||||
|
@ -34,7 +34,7 @@ namespace Boats
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityBoat(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
|
@ -35,8 +35,7 @@ namespace Boats
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_boat = new DrawingBoat();
|
||||
_boat.Init(
|
||||
_boat = new DrawingBoat(
|
||||
rnd.Next(100, 300),
|
||||
rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256),
|
||||
|
Loading…
x
Reference in New Issue
Block a user