Добавление конструкторов
This commit is contained in:
parent
34fcedd0b7
commit
b74e5b9fba
@ -22,9 +22,8 @@ public class DrawingArmoredCar {
|
||||
return armoredCar;
|
||||
}
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor) {
|
||||
this.armoredCar = new EntityArmoredCar();
|
||||
this.armoredCar.init(speed, weight, bodyColor);
|
||||
public DrawingArmoredCar(int speed, float weight, Color bodyColor) {
|
||||
this.armoredCar = new EntityArmoredCar(speed, weight, bodyColor);
|
||||
Random r = new Random();
|
||||
this.drawingCaterpillar = new DrawingCaterpillar();
|
||||
this.drawingCaterpillar.Init(r.nextInt(4, 7), bodyColor);
|
||||
|
@ -7,7 +7,7 @@ public class EntityArmoredCar {
|
||||
private Color bodyColor;
|
||||
public float step;
|
||||
|
||||
public void init(int speed, float weight, Color bodyColor) {
|
||||
public EntityArmoredCar(int speed, float weight, Color bodyColor) {
|
||||
this.speed = speed;
|
||||
this.weight = weight;
|
||||
this.bodyColor = bodyColor;
|
||||
|
@ -42,8 +42,7 @@ public class FormArmoredCar extends JFrame{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
Random rnd = new Random();
|
||||
armoredCar = new DrawingArmoredCar();
|
||||
armoredCar.Init(rnd.nextInt(100,300), rnd.nextInt(1000, 2000),
|
||||
armoredCar = new DrawingArmoredCar(rnd.nextInt(100,300), rnd.nextInt(1000, 2000),
|
||||
new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
|
||||
armoredCar.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100),
|
||||
|
Loading…
Reference in New Issue
Block a user