Mochalov D.V. Hard LabWork02 #2

Merged
eegov merged 14 commits from LabWork02 into LabWork01 2022-10-21 10:06:17 +04:00
2 changed files with 18 additions and 10 deletions
Showing only changes of commit b18173f05a - Show all commits

View File

@ -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);

View File

@ -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;
}
}
}