Перевод на конструкторы 2

This commit is contained in:
prodigygirl 2022-10-22 22:46:44 +04:00
parent 5e6e077ef5
commit 2fd750d255
2 changed files with 2 additions and 3 deletions

View File

@ -25,8 +25,7 @@ public class DrawingArmoredCar {
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);
this.drawingCaterpillar = new DrawingCaterpillar(r.nextInt(4, 7), bodyColor);
}
protected DrawingArmoredCar(int speed, float weight, Color bodyColor, int carWidth, int carHeight) {

View File

@ -4,7 +4,7 @@ public class DrawingCaterpillar {
private NumRinks numRinks = NumRinks.Four;
private Color color;
public void Init(int n, Color color) {
public DrawingCaterpillar(int n, Color color) {
setNumRinks(n);
this.color = color;
}