Pibd-23_Zhelovanov_D.Y._Bat.../EntityBattleship.java

42 lines
1.1 KiB
Java
Raw Normal View History

2022-10-24 22:01:54 +04:00
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;
}
}