From 0ea7fea345dab5f729df0ed629cefee4acd87f76 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Thu, 26 Oct 2023 23:57:01 +0400 Subject: [PATCH] some minor fixes p.2 --- src/drawing_objects/DrawingBattleship.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/drawing_objects/DrawingBattleship.java b/src/drawing_objects/DrawingBattleship.java index 00623af..0da0e6c 100644 --- a/src/drawing_objects/DrawingBattleship.java +++ b/src/drawing_objects/DrawingBattleship.java @@ -14,14 +14,14 @@ public class DrawingBattleship { private int pictureHeight; private int startPosX; private int startPosY; - private final int shipWidth = 150; - public int getShipWidth() {return shipWidth;} - private final int shipHeight = 50; - public int getShipHeight() {return shipHeight;} + private final int SHIP_WIDTH = 150; + public int getShipWidth() {return SHIP_WIDTH;} + private final int SHIP_HEIGHT = 50; + public int getShipHeight() {return SHIP_HEIGHT;} private DrawingBlocks drawingBlocks; public boolean init(int speed, double weight, Color bodyColor, Color additionalColor, boolean turret, boolean rocketLauncher, int width, int height, int blocksNumber) { - if (width < shipWidth || height < shipHeight) + if (width < SHIP_WIDTH || height < SHIP_HEIGHT) return false; pictureWidth = width; pictureHeight = height; @@ -32,7 +32,7 @@ public class DrawingBattleship { return true; } public void setPosition(int x, int y) { - if (x < 0 || y < 0 || x + shipWidth > pictureWidth || y + shipHeight > pictureHeight) { + if (x < 0 || y < 0 || x + SHIP_WIDTH > pictureWidth || y + SHIP_HEIGHT > pictureHeight) { x = 0; y = 0; } @@ -55,12 +55,12 @@ public class DrawingBattleship { break; // вправо case RIGHT: - if (startPosX + shipWidth + entityBattleship.step.get().intValue() < pictureWidth) + if (startPosX + SHIP_WIDTH + entityBattleship.step.get().intValue() < pictureWidth) startPosX += entityBattleship.step.get().intValue(); break; //вниз case DOWN: - if (startPosY + shipHeight + entityBattleship.step.get().intValue() < pictureHeight) + if (startPosY + SHIP_HEIGHT + entityBattleship.step.get().intValue() < pictureHeight) startPosY += entityBattleship.step.get().intValue(); break; }