Создание класса-сущности.

This commit is contained in:
Артем Харламов 2022-12-17 22:11:24 +04:00
parent 49ba085587
commit 79ad67c00f

33
EntityStormtrooper.java Normal file
View File

@ -0,0 +1,33 @@
import java.awt.Color;
import java.util.Random;
public class EntityStormtrooper {
private int Speed = 0;
private float Weight = 0;
private Color BodyColor;
public float Step;
public int getSpeed() {
return Speed;
}
public float getWeight() {
return Weight;
}
public Color getBodyColor() {
return BodyColor;
}
public void Init(int speed, float weight, Color bodyColor){
Random rnd = new Random();
Speed = speed <= 0 ? rnd.nextInt(50 + 1) +50 : speed; //генерация в диапазоне от 50 до 100
Weight = weight <= 0 ? rnd.nextInt(50 + 1) +50 : weight;
Step = Speed * 100 / Weight;
BodyColor = bodyColor;
}
}