Исправления: замена модификатора поля на private, добавление getter-метода
This commit is contained in:
parent
7ee149d5bc
commit
9bf470f992
@ -2,7 +2,7 @@ import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class DrawingArmoredCar {
|
||||
public EntityArmoredCar armoredCar;
|
||||
private EntityArmoredCar armoredCar;
|
||||
|
||||
private float startPosX;
|
||||
|
||||
@ -18,6 +18,10 @@ public class DrawingArmoredCar {
|
||||
|
||||
private DrawingCaterpillar drawingCaterpillar;
|
||||
|
||||
public EntityArmoredCar getArmoredCar() {
|
||||
return armoredCar;
|
||||
}
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor) {
|
||||
this.armoredCar = new EntityArmoredCar();
|
||||
this.armoredCar.init(speed, weight, bodyColor);
|
||||
@ -27,7 +31,7 @@ public class DrawingArmoredCar {
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y, int width, int height) {
|
||||
if (x > 0 && y > 0 && x + carWidth < width && y + carHeight < height) {
|
||||
if (x >= 0 && y >= 0 && x + carWidth < width && y + carHeight < height) {
|
||||
startPosX = x;
|
||||
startPosY = y;
|
||||
pictureWidth = width;
|
||||
|
@ -21,7 +21,6 @@ public class DrawingCaterpillar {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void DrawCaterpillar(Graphics2D g2d, int startPosX, int startPosY)
|
||||
|
@ -49,9 +49,9 @@ public class FormCar extends JFrame{
|
||||
armoredCar.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10,
|
||||
drawPanel.getWidth(), drawPanel.getHeight());
|
||||
|
||||
labelSpeed.setText("Скорость: " + armoredCar.armoredCar.getSpeed());
|
||||
labelWeight.setText("Вес: " + armoredCar.armoredCar.getWeight());
|
||||
labelColor.setText("Цвет: " + armoredCar.armoredCar.getWeight());
|
||||
labelSpeed.setText("Скорость: " + armoredCar.getArmoredCar().getSpeed());
|
||||
labelWeight.setText("Вес: " + armoredCar.getArmoredCar().getWeight());
|
||||
labelColor.setText("Цвет: " + armoredCar.getArmoredCar().getWeight());
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user