From b28bb84cf831eaf30a1a946f52098f21f68cfdfb Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Fri, 21 Oct 2022 21:53:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=20=D1=86=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=D0=B0=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=BB=D0=BE=D0=BA=D0=BE=D0=BC=D0=BE?= =?UTF-8?q?=D1=82=D0=B8=D0=B2=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FormLocomotive.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/FormLocomotive.java b/FormLocomotive.java index 7eca30a..ed8a82e 100644 --- a/FormLocomotive.java +++ b/FormLocomotive.java @@ -23,7 +23,10 @@ public class FormLocomotive extends JComponent{ JButton createButton = new JButton("Create"); createButton.addActionListener(e -> { Random rnd = new Random(); - _locomotive = new DrawningLocomotive(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))); + + Color colorFirst = JColorChooser.showDialog(null, "Цвет", new Color(rnd.nextInt(256), rnd.nextInt(256),rnd.nextInt(256))); + + _locomotive = new DrawningLocomotive(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, colorFirst); _locomotive.SetPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), 800, 500-75); speedLabel.setText("Speed: " + _locomotive.Locomotive.getSpeed()); weightLabel.setText("Weight: " + (int)_locomotive.Locomotive.getWeight()); @@ -34,9 +37,13 @@ public class FormLocomotive extends JComponent{ JButton modifiedButton = new JButton("Modified"); modifiedButton.addActionListener(e -> { Random rnd = new Random(); + + Color colorFirst = JColorChooser.showDialog(null, "Цвет", new Color(rnd.nextInt(256), rnd.nextInt(256),rnd.nextInt(256))); + Color colorSecond = JColorChooser.showDialog(null, "Цвет", new Color(rnd.nextInt(256), rnd.nextInt(256),rnd.nextInt(256))); + _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)), + colorFirst, + colorSecond, rnd.nextBoolean(), rnd.nextBoolean()); _locomotive.SetPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), 800, 500 - 75);