2022-10-24 22:01:54 +04:00
|
|
|
import java.awt.*;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class EntityBattleship {
|
2022-11-21 23:52:48 +04:00
|
|
|
private int speed = 0;
|
|
|
|
private float weight = 0;
|
|
|
|
Color bodyColor;
|
2022-10-24 22:01:54 +04:00
|
|
|
public int GetSpeed() {
|
|
|
|
return speed;
|
|
|
|
}
|
|
|
|
public float GetWeight() {
|
|
|
|
return weight;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// Цвет корпуса
|
|
|
|
/// </summary>
|
|
|
|
public Color GetBodyColor() {
|
2022-11-21 23:52:48 +04:00
|
|
|
return bodyColor;
|
2022-10-24 22:01:54 +04:00
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// Шаг перемещения корабля
|
|
|
|
/// </summary>
|
|
|
|
public float GetStep(){
|
|
|
|
return speed * 100 / weight;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// Инициализация полей объекта-класса корабля
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="speed"></param>
|
|
|
|
/// <param name="weight"></param>
|
|
|
|
/// <param name="bodyColor"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public void Init(int speed, float weight, Color bodyColor)
|
|
|
|
{
|
|
|
|
Random rnd = new Random();
|
2022-11-21 23:52:48 +04:00
|
|
|
this.speed = speed <= 0 ? rnd.nextInt(950) + 1050 : speed;
|
|
|
|
this.weight = weight <= 0 ? rnd.nextInt(40) + 70 : weight;
|
|
|
|
this.bodyColor = bodyColor;
|
2022-10-24 22:01:54 +04:00
|
|
|
}
|
|
|
|
}
|