PIbd-23_Minhasapov_R.H._Exc.../EntityTracktor.java

32 lines
807 B
Java
Raw Normal View History

import java.awt.*;
import java.util.Random;
// Класс-сущность "Трактор"
public class EntityTracktor {
private int Speed;
private float Weight;
private Color BodyColor;
public int getSpeed() {
return Speed;
}
public float getWeight(){
return Weight;
}
public Color getBodyColor(){
return BodyColor;
}
public float getStep(){
return Speed * 100 / Weight;
}
// Инициализация полей объекта-класса Трактора
public void Init(int speed, float weight, Color bodyColor)
{
Random rnd = new Random();
Speed = speed <= 0 ? rnd.nextInt(50, 150) : speed;
Weight = weight <= 0 ? rnd.nextInt(40, 70) : weight;
BodyColor = bodyColor;
}
}