41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
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;
|
|
}
|
|
/// <summary>
|
|
/// Цвет корпуса
|
|
/// </summary>
|
|
public Color GetBodyColor() {
|
|
return bodyColor;
|
|
}
|
|
/// <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 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;
|
|
}
|
|
}
|