diff --git a/ProjectContainerShip/src/DrawingShip/DrawingContainerShip.java b/ProjectContainerShip/src/DrawingShip/DrawingContainerShip.java index d2a4063..08d7958 100644 --- a/ProjectContainerShip/src/DrawingShip/DrawingContainerShip.java +++ b/ProjectContainerShip/src/DrawingShip/DrawingContainerShip.java @@ -1,5 +1,5 @@ package DrawingShip; -import Entities.EntityContainerShip; +import DiffDecks.DecksCount; import Entities.EntityContainerShip; import java.awt.*; @@ -9,28 +9,39 @@ public class DrawingContainerShip extends DrawingShip { EntityShip = new EntityContainerShip(speed, weight, bodycolor, additionalcolor, crane, container); SetAmountandTypeDecks(); } + @Override public void DrawTransport(Graphics2D g) { if (EntityShip == null || !(EntityShip instanceof EntityContainerShip containerShip) || _StartPosX == null || _StartPosY == null) return; - int y = _StartPosY; + + int originalStartPosY = _StartPosY; + int containerOffsetY = 0; + if (containerShip.Crane) { int craneX = _StartPosX + drawingShipWidth - 40; int craneY = _StartPosY + drawingShipHeight - 90; - //кран + + g.setColor(Color.BLACK); g.drawLine(craneX + 10, craneY + 40, craneX + 10, craneY); g.drawLine(craneX + 10, craneY, craneX + 50, craneY); g.drawLine(craneX + 10, craneY, craneX + 50, craneY + 5); g.drawLine(craneX + 50, craneY, craneX + 50, craneY + 30); - // хваталка крана + g.drawLine(craneX + 40, craneY + 30, craneX + 60, craneY + 30); g.drawLine(craneX + 40, craneY + 30, craneX + 40, craneY + 35); g.drawLine(craneX + 60, craneY + 30, craneX + 60, craneY + 35); - _StartPosY += 30; + containerOffsetY += 30; } + + + _StartPosY += containerOffsetY; super.DrawTransport(g); + _StartPosY = originalStartPosY; + + int count_decks = 0; if (drawingDecks.getNumberOfDecks() != null) { switch (drawingDecks.getNumberOfDecks()) { @@ -45,19 +56,27 @@ public class DrawingContainerShip extends DrawingShip { break; } } - if (containerShip.Container) { - g.setColor(Color.BLACK); - g.drawRect(_StartPosX + 70, _StartPosY + 15, 40, 15); - g.setColor(containerShip.getAdditionalColor()); - g.fillRect(_StartPosX + 70, _StartPosY + 15, 40, 15); - g.setColor(Color.BLACK); - g.drawRect(_StartPosX + 90, _StartPosY + 20, 40, 15); - g.setColor(containerShip.getAdditionalColor()); - g.fillRect(_StartPosX + 90, _StartPosY + 20, 40, 15); + int containerY; + if (count_decks == 0) { + containerY = _StartPosY + 15; + } else { + containerY = _StartPosY + 15 + containerOffsetY; } + + if (containerShip.Container) { + // Draw containers + g.setColor(Color.BLACK); + g.drawRect(_StartPosX + 40, containerY, 40, 15); + g.setColor(containerShip.getAdditionalColor()); + g.fillRect(_StartPosX + 40, containerY, 40, 15); + g.setColor(Color.BLACK); + g.drawRect(_StartPosX + 60, containerY + 5, 40, 15); + g.setColor(containerShip.getAdditionalColor()); + g.fillRect(_StartPosX + 60, containerY + 5, 40, 15); + } + if (containerShip.Crane) { - _StartPosY -= 30; drawingShipHeight += 30; } } diff --git a/ProjectContainerShip/src/DrawingShip/DrawingShip.java b/ProjectContainerShip/src/DrawingShip/DrawingShip.java index 4a7862d..f41ddfc 100644 --- a/ProjectContainerShip/src/DrawingShip/DrawingShip.java +++ b/ProjectContainerShip/src/DrawingShip/DrawingShip.java @@ -119,6 +119,7 @@ public class DrawingShip extends JPanel { int y = _StartPosY; g.setColor(EntityShip.getBodyColor()); if (drawingDecks.getNumberOfDecks() != null) { + y += 30; switch (drawingDecks.getNumberOfDecks()) { case OneDeck: drawingDecks.DrawDecks(g, _StartPosX + 30, y, 80, 15, EntityShip.getBodyColor()); diff --git a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DiffDecks/DeckType2.class b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DiffDecks/DeckType2.class index d746e9e..cce6d0f 100644 Binary files a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DiffDecks/DeckType2.class and b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DiffDecks/DeckType2.class differ diff --git a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingContainerShip$1.class b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingContainerShip$1.class index 2e786d1..7490968 100644 Binary files a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingContainerShip$1.class and b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingContainerShip$1.class differ diff --git a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingContainerShip.class b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingContainerShip.class index 5651b9b..596c3c4 100644 Binary files a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingContainerShip.class and b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingContainerShip.class differ diff --git a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingShip$1.class b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingShip$1.class index 2f967cc..46cd0f3 100644 Binary files a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingShip$1.class and b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingShip$1.class differ diff --git a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingShip.class b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingShip.class index ed16ba8..4650c05 100644 Binary files a/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingShip.class and b/out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/DrawingShip/DrawingShip.class differ