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

41 lines
818 B
Java

import java.awt.*;
import java.util.Random;
public class EntityLocomotive {
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 void Init(int speed, float weight, Color bodyColor)
{
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;
}
}