Work is done 02

This commit is contained in:
Сергей Полевой 2022-10-08 23:03:27 +04:00
parent 1ef0f5465b
commit fb4c5f3416
3 changed files with 18 additions and 2 deletions

View File

@ -16,7 +16,7 @@ public class DrawingArtillery {
public DrawingArtillery(int speed, float weight, Color bodyColor, int rollersCount) {
artillery = new EntityArtillery(speed, weight, bodyColor);
drawingRollers = new DrawingRollers(rollersCount, bodyColor);
drawingRollers = RollersType.random(rollersCount, bodyColor);
}
protected DrawingArtillery(int speed, float weight, Color bodyColor, int rollersCount, int artilleryWidth, int artilleryHeight) {

View File

@ -1,5 +1,4 @@
import java.awt.*;
import java.awt.geom.Line2D;
public class DrawingCrossRollers implements IDrawingRollers {
private RollersCount rollersCount;

17
RollersType.java Normal file
View File

@ -0,0 +1,17 @@
import java.awt.*;
import java.util.Random;
public enum RollersType {
Standard,
Squared,
Cross;
public static IDrawingRollers random(int rollersCount, Color bodyColor) {
return switch (new Random().nextInt(RollersType.values().length)) {
case 0 -> new DrawingRollers(rollersCount, bodyColor);
case 1 -> new DrawingSquaredRollers(rollersCount, bodyColor);
case 2 -> new DrawingCrossRollers(rollersCount, bodyColor);
default -> null;
};
}
}