ПИбд-12, Шляпин Юрий Александрович, 1 сложная #1
@ -30,7 +30,16 @@ public class AircraftCarrierController implements Initializable {
|
||||
private TextField inputCountBlocks;
|
||||
@FXML
|
||||
protected void buttonCreate_Click() {
|
||||
drawingAircraftCarrier = new DrawingAircraftCarrier(
|
||||
drawingAircraftCarrier = new DrawingAircraftCarrier();
|
||||
int inputCountBlock;
|
||||
|
||||
try {
|
||||
inputCountBlock = Integer.parseInt(inputCountBlocks.getCharacters().toString());
|
||||
} catch (NumberFormatException ignored) {
|
||||
inputCountBlock = 0;
|
||||
}
|
||||
|
||||
drawingAircraftCarrier.Init(
|
||||
random.nextInt(100) + 100,
|
||||
random.nextInt(1000) + 1000,
|
||||
Color.rgb(
|
||||
@ -44,13 +53,10 @@ public class AircraftCarrierController implements Initializable {
|
||||
random.nextInt(256)
|
||||
),
|
||||
random.nextBoolean(),
|
||||
random.nextBoolean()
|
||||
random.nextBoolean(),
|
||||
inputCountBlock
|
||||
);
|
||||
|
||||
try {
|
||||
drawingAircraftCarrier.setDrawingBlock(Integer.parseInt(inputCountBlocks.getCharacters().toString()));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
|
||||
drawingAircraftCarrier.setCanvasWidth((int) canvas.getWidth());
|
||||
drawingAircraftCarrier.setCanvasHeight((int) canvas.getHeight());
|
||||
if (
|
||||
|
@ -16,29 +16,33 @@ public class DrawingAircraftCarrier {
|
||||
private static final int widthPicture = 250;
|
||||
private static final int heightPicture = 100;
|
||||
|
||||
public DrawingAircraftCarrier(
|
||||
public void Init(
|
||||
int speed,
|
||||
int weight,
|
||||
Color primaryColor,
|
||||
Color secondaryColor,
|
||||
boolean hasDeck,
|
||||
boolean hasСabin
|
||||
boolean hasСabin,
|
||||
int countBlock
|
||||
) {
|
||||
aircraftCarrier = new EntityAircraftCarrier(speed,
|
||||
aircraftCarrier = new EntityAircraftCarrier();
|
||||
aircraftCarrier.Init(speed,
|
||||
weight,
|
||||
primaryColor,
|
||||
secondaryColor,
|
||||
hasDeck,
|
||||
hasСabin);
|
||||
hasСabin
|
||||
);
|
||||
drawingBlock = new DrawingBlock();
|
||||
drawingBlock.setBlockCount(countBlock);
|
||||
}
|
||||
|
||||
public void setDrawingBlock(int count) {
|
||||
drawingBlock = new DrawingBlock();
|
||||
drawingBlock.setBlockCount(count);
|
||||
}
|
||||
|
||||
public void setCanvasWidth(int width) {
|
||||
if (x+widthPicture > width);
|
||||
if (x+widthPicture > width) return;
|
||||
widthCanvas = width;
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,8 @@ import javafx.scene.paint.Color;
|
||||
public class DrawingBlock {
|
||||
private BlockCount blockCount;
|
||||
|
||||
public DrawingBlock() {}
|
||||
public DrawingBlock(int blockCountValue) {
|
||||
this.blockCount = BlockCount.GetBlockCount(blockCountValue);
|
||||
}
|
||||
|
||||
public void setBlockCount(int blockCountValue) {
|
||||
this.blockCount = BlockCount.GetBlockCount(blockCountValue);
|
||||
this.blockCount = BlockCount.ConvertToBlockCount(blockCountValue);
|
||||
}
|
||||
|
||||
private void DrawTwoBlock(GraphicsContext gc, int x, int y, Color color) {
|
||||
|
@ -12,7 +12,7 @@ public class EntityAircraftCarrier {
|
||||
private boolean HasСabin;
|
||||
|
||||
|
||||
public EntityAircraftCarrier(
|
||||
public void Init(
|
||||
int speed,
|
||||
double weight,
|
||||
Color primaryColor,
|
||||
|
@ -16,7 +16,7 @@ public enum BlockCount {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public static BlockCount GetBlockCount(int count) {
|
||||
public static BlockCount ConvertToBlockCount(int count) {
|
||||
return switch (count) {
|
||||
case 2 -> Two;
|
||||
case 4 -> Four;
|
||||
|
Loading…
x
Reference in New Issue
Block a user