diff --git a/DrawningWarmlyLocomotive.java b/DrawningWarmlyLocomotive.java new file mode 100644 index 0000000..8b9324f --- /dev/null +++ b/DrawningWarmlyLocomotive.java @@ -0,0 +1,30 @@ +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); + Locomotive = new EntityWarmlyLocomotive(speed, weight, bodyColor, extraColor, pipe, storage); + } + public void DrawTransport(Graphics g) + { + if (Locomotive instanceof EntityWarmlyLocomotive) + { + EntityWarmlyLocomotive warmlyLocomotive = (EntityWarmlyLocomotive) Locomotive; + //Pen pen = new(Color.Black); + //Brush extraBrush = new SolidBrush(warmlyLocomotive.ExtraColor); + super.DrawTransport((Graphics2D)g); + + if (warmlyLocomotive.Pipe) + { + //TODO + + } + + if (warmlyLocomotive.FuelStorage) + { + //TODO + + } + } + } +} diff --git a/EntityWarmlyLocomotive.java b/EntityWarmlyLocomotive.java new file mode 100644 index 0000000..2e1a502 --- /dev/null +++ b/EntityWarmlyLocomotive.java @@ -0,0 +1,15 @@ +import java.awt.*; + +public class EntityWarmlyLocomotive extends EntityLocomotive{ + public final Color ExtraColor; + public final boolean Pipe; + public final boolean FuelStorage; + public EntityWarmlyLocomotive (int speed, float weight, Color bodyColor, Color extraColor, boolean pipe, boolean fuelStorage) + { + super(speed, weight, bodyColor); + ExtraColor = extraColor; + Pipe = pipe; + FuelStorage = fuelStorage; + } + +} diff --git a/FormLocomotive.java b/FormLocomotive.java index 55b048b..6616754 100644 --- a/FormLocomotive.java +++ b/FormLocomotive.java @@ -47,7 +47,23 @@ public class FormLocomotive extends JComponent{ repaint(); }); + JButton modifiedButton = new JButton("Modified"); + modifiedButton.addActionListener(e -> { + Random rnd = new Random(); + _locomotive = new DrawningWarmlyLocomotive(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, + new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)), + new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)), + rnd.nextBoolean(), + rnd.nextBoolean()); + _locomotive.SetPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), formFrame.getWidth(), formFrame.getHeight() - 75); + speedLabel.setText("Speed: " + _locomotive.Locomotive.getSpeed()); + weightLabel.setText("Weight: " + (int)_locomotive.Locomotive.getWeight()); + colorLabel.setText("Color: " + _locomotive.Locomotive.getBodyColor().getRed() + " " + _locomotive.Locomotive.getBodyColor().getGreen() + " " + _locomotive.Locomotive.getBodyColor().getBlue() ); + repaint(); + }); + statusPanel.add(createButton); + statusPanel.add(modifiedButton); statusPanel.add(speedLabel); statusPanel.add(weightLabel); statusPanel.add(colorLabel); @@ -84,6 +100,8 @@ public class FormLocomotive extends JComponent{ formFrame.getContentPane().add(this); } + + @Override protected void paintComponent(Graphics g) { super.paintComponent(g);