Constructors have been added
This commit is contained in:
parent
7ea460dab0
commit
02566d7957
@ -14,11 +14,9 @@ public class DrawingArtillery {
|
||||
return artillery;
|
||||
}
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor, int rollersCount) {
|
||||
artillery = new EntityArtillery();
|
||||
artillery.Init(speed, weight, bodyColor);
|
||||
drawingRollers = new DrawingRollers();
|
||||
drawingRollers.Init(rollersCount, bodyColor);
|
||||
public DrawingArtillery(int speed, float weight, Color bodyColor, int rollersCount) {
|
||||
artillery = new EntityArtillery(speed, weight, bodyColor);
|
||||
drawingRollers = new DrawingRollers(rollersCount, bodyColor);
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y, int width, int height) {
|
||||
|
@ -4,7 +4,7 @@ public class DrawingRollers {
|
||||
private RollersCount rollersCount;
|
||||
private Color color;
|
||||
|
||||
public void Init(int rollersCount, Color bodyColor) {
|
||||
public DrawingRollers(int rollersCount, Color bodyColor) {
|
||||
setRollersCount(rollersCount);
|
||||
color = bodyColor;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ public class EntityArtillery {
|
||||
private float weight;
|
||||
private Color bodyColor;
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor) {
|
||||
public EntityArtillery(int speed, float weight, Color bodyColor) {
|
||||
Random rnd = new Random();
|
||||
this.speed = speed <= 0 ? rnd.nextInt(50, 150) : speed;
|
||||
this.weight = weight <= 0 ? rnd.nextInt(40, 70) : weight;
|
||||
|
@ -23,15 +23,14 @@ public class FormArtillery extends JFrame {
|
||||
this.setContentPane(artilleryPane);
|
||||
createButton.addActionListener(e -> {
|
||||
Random rnd = new Random();
|
||||
_artillery = new DrawingArtillery();
|
||||
_artillery.Init(
|
||||
rnd.nextInt(100, 300),
|
||||
rnd.nextInt(1000, 2000),
|
||||
new Color(
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256)),
|
||||
rnd.nextInt(4, 7)
|
||||
_artillery = new DrawingArtillery(
|
||||
rnd.nextInt(100, 300),
|
||||
rnd.nextInt(1000, 2000),
|
||||
new Color(
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256)),
|
||||
rnd.nextInt(4, 7)
|
||||
);
|
||||
_artillery.SetPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), pictureBox.getWidth(), pictureBox.getHeight());
|
||||
speedLabel.setText(String.format("Скорость: %s", _artillery.getArtillery().getSpeed()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user