42 lines
1.1 KiB
Java
42 lines
1.1 KiB
Java
import java.awt.*;
|
|
import java.util.Random;
|
|
|
|
public class EntityBattleship {
|
|
private int speed;
|
|
private float weight;
|
|
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 void Init(int speed, float weight, Color bodyColor)
|
|
{
|
|
Random rnd = new Random();
|
|
if(speed <= 0) speed = rnd.nextInt(50, 150);
|
|
if(weight <= 0) weight = rnd.nextInt(40, 70);
|
|
|
|
BodyColor = bodyColor;
|
|
}
|
|
}
|