From b18173f05ac0c8032864f1dfa15774cdf0a36a13 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Sat, 8 Oct 2022 18:55:47 +0400 Subject: [PATCH] Fixed DrawningWarmlyLocomotive --- DrawningLocomotive.java | 2 +- DrawningWarmlyLocomotive.java | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/DrawningLocomotive.java b/DrawningLocomotive.java index 1e78705..bc3cbef 100644 --- a/DrawningLocomotive.java +++ b/DrawningLocomotive.java @@ -100,7 +100,7 @@ class DrawningLocomotive { } //тело g.setColor(Color.BLACK); - g.drawRect((int)_startPosX , (int)_startPosY, _locomotiveWidth - 20, _locomotiveHeight - 10); + g.drawRect((int)_startPosX , (int)_startPosY, 110 - 10, 50 - 10); //окна g.setColor(Locomotive.getBodyColor()); g.fillRect((int)_startPosX + 10, (int)_startPosY + 10, 10, 10); diff --git a/DrawningWarmlyLocomotive.java b/DrawningWarmlyLocomotive.java index 8b9324f..cdc0625 100644 --- a/DrawningWarmlyLocomotive.java +++ b/DrawningWarmlyLocomotive.java @@ -2,29 +2,37 @@ import java.awt.*; public class DrawningWarmlyLocomotive extends DrawningLocomotive{ public DrawningWarmlyLocomotive(int speed, float weight, Color bodyColor, Color extraColor, boolean pipe, boolean storage) { - super(speed, weight, bodyColor, 110, 50); + super(speed, weight, bodyColor, 130, 70); Locomotive = new EntityWarmlyLocomotive(speed, weight, bodyColor, extraColor, pipe, storage); } - public void DrawTransport(Graphics g) + @Override + public void DrawTransport(Graphics2D g) { if (Locomotive instanceof EntityWarmlyLocomotive) { EntityWarmlyLocomotive warmlyLocomotive = (EntityWarmlyLocomotive) Locomotive; - //Pen pen = new(Color.Black); - //Brush extraBrush = new SolidBrush(warmlyLocomotive.ExtraColor); - super.DrawTransport((Graphics2D)g); + + g.setColor(warmlyLocomotive.ExtraColor); if (warmlyLocomotive.Pipe) { - //TODO - + g.fillRect((int)_startPosX + 10, (int)_startPosY, 30, 20); + g.fillRect((int)_startPosX + 60, (int)_startPosY, 20, 20); + g.fillRect((int)_startPosX + 60, (int)_startPosY + 10, 30, 10); } if (warmlyLocomotive.FuelStorage) { - //TODO - + g.fillRect((int)_startPosX + 110, (int)_startPosY + 10, 10, 50); + g.fillRect((int)_startPosX + 110, (int)_startPosY + 40, 20, 20); + g.fillRect((int)_startPosX + 110, (int)_startPosY, 30, 10); } + + _startPosY += 20; + + super.DrawTransport((Graphics2D)g); + + _startPosY -= 20; } } }