PIbd-23_Mochalov_D.V._Locom.../EntityLocomotive.java

41 lines
825 B
Java
Raw Normal View History

2022-09-24 16:48:31 +04:00
import java.awt.*;
2022-09-24 17:19:00 +04:00
import java.util.Random;
2022-09-24 16:48:31 +04:00
public class EntityLocomotive {
2022-09-24 17:19:00 +04:00
private int Speed;
public int getSpeed() {
return Speed;
}
private float Weight;
public float getWeight() {
return Weight;
}
private Color BodyColor;
public Color getBodyColor() {
return BodyColor;
}
public float Step () {
return Speed * 100 / Weight;
}
public EntityLocomotive(int speed, float weight, Color bodyColor)
2022-09-24 17:19:00 +04:00
{
Random rnd = new Random();
if (speed <= 0) {
Speed = 50 + rnd.nextInt(100);
}
else {
Speed = speed;
}
if (weight <= 0) {
Weight = 40 + rnd.nextInt(30);
}
else {
Weight = weight;
}
BodyColor = bodyColor;
}
2022-09-24 16:48:31 +04:00
}