import java.awt.*; import java.util.Random; public class EntityBattleship { private int speed = 0; private float weight = 0; Color bodyColor; public int GetSpeed() { return speed; } public float GetWeight() { return weight; } /// /// Цвет корпуса /// public Color GetBodyColor() { return bodyColor; } /// /// Шаг перемещения корабля /// public float GetStep(){ return speed * 100 / weight; } /// /// Инициализация полей объекта-класса корабля /// /// /// /// /// public EntityBattleship(int speed, float weight, Color bodyColor) { Random rnd = new Random(); this.speed = speed <= 0 ? rnd.nextInt(950) + 1050 : speed; this.weight = weight <= 0 ? rnd.nextInt(40) + 70 : weight; this.bodyColor = bodyColor; } }