Borschevskaya A.A. Lab Work 2 Hard #2

Merged
eegov merged 16 commits from lab2 into lab1 2022-11-07 10:48:13 +04:00
4 changed files with 11 additions and 10 deletions
Showing only changes of commit 588661f027 - Show all commits

View File

@ -25,10 +25,14 @@ public class DrawingArmoredCar {
public DrawingArmoredCar(int speed, float weight, Color bodyColor) {
this.armoredCar = new EntityArmoredCar(speed, weight, bodyColor);
IDrawingCaterpillar[] realisations = new IDrawingCaterpillar[]{
Review

Требовалось создание объекта, а не массива объектов

Требовалось создание объекта, а не массива объектов
new DrawingCaterpillar(bodyColor),
new DrawingCrossCaterpillar(bodyColor),
new DrawingDoubleCaterpillar(bodyColor)};
Random r = new Random();
IDrawingCaterpillar[] realisations = new IDrawingCaterpillar[]{new DrawingCaterpillar(r.nextInt(4, 7), bodyColor),
new DrawingCrossCaterpillar(r.nextInt(4, 7), bodyColor), new DrawingDoubleCaterpillar(r.nextInt(4, 7), bodyColor)};
int num = r.nextInt(4, 7);
this.drawingCaterpillar = realisations[r.nextInt(3)];
drawingCaterpillar.setNumRinks(num);
}
protected DrawingArmoredCar(int speed, float weight, Color bodyColor, int carWidth, int carHeight) {

View File

@ -4,11 +4,10 @@ public class DrawingCaterpillar implements IDrawingCaterpillar {
private NumRinks numRinks = NumRinks.Four;
private Color color;
public DrawingCaterpillar(int n, Color color) {
setNumRinks(n);
public DrawingCaterpillar(Color color) {
this.color = color;
}
@Override
public void setNumRinks(int n) {
switch (n) {
case 4 -> numRinks = NumRinks.Four;
@ -22,7 +21,7 @@ public class DrawingCaterpillar implements IDrawingCaterpillar {
}
}
}
@Override
public void DrawCaterpillar(Graphics2D g2d, int startPosX, int startPosY)
{
color = color != null ? color : Color.YELLOW;

View File

@ -4,8 +4,7 @@ public class DrawingCrossCaterpillar implements IDrawingCaterpillar{
private NumRinks numRinks = NumRinks.Four;
private Color color;
public DrawingCrossCaterpillar(int n, Color color) {
setNumRinks(n);
public DrawingCrossCaterpillar(Color color) {
this.color = color;
}

View File

@ -4,8 +4,7 @@ public class DrawingDoubleCaterpillar implements IDrawingCaterpillar{
private NumRinks numRinks = NumRinks.Four;
private Color color;
public DrawingDoubleCaterpillar(int n, Color color) {
setNumRinks(n);
public DrawingDoubleCaterpillar(Color color) {
this.color = color;
}