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

41 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 = 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() {
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>
2022-12-06 17:23:28 +04:00
public EntityBattleship(int speed, float weight, Color bodyColor)
2022-10-24 22:01:54 +04:00
{
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;
2022-10-24 22:01:54 +04:00
}
}