Переход на конструкторы

This commit is contained in:
Nikita Potapov 2022-11-04 11:54:35 +04:00
parent 53d1bef6d8
commit 6b21c79439
3 changed files with 4 additions and 6 deletions

View File

@ -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>
/// Установка позиции лодки

View File

@ -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;

View File

@ -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),