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

44 lines
898 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 void SetColor(Color color) {
BodyColor = color;
}
public float Step () {
return Speed * 100 / Weight;
}
public EntityLocomotive(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;
}
}