From 92a11ea687ef37c126ef8407f4e2c5ca7ec533e3 Mon Sep 17 00:00:00 2001 From: Safgerd Date: Sat, 5 Nov 2022 23:32:00 +0400 Subject: [PATCH] =?UTF-8?q?LabWork01:=20=D0=97=D0=B0=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D1=88=D0=B5=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawningTracktor.java | 1 + FormTracktor.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DrawningTracktor.java b/DrawningTracktor.java index e06d3b6..81d5ab1 100644 --- a/DrawningTracktor.java +++ b/DrawningTracktor.java @@ -79,6 +79,7 @@ public class DrawningTracktor { break; } } + // Отрисовка Трактора public void DrawTransport(Graphics g) { diff --git a/FormTracktor.java b/FormTracktor.java index 3d092b2..74b9158 100644 --- a/FormTracktor.java +++ b/FormTracktor.java @@ -2,8 +2,6 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.Random; public class FormTracktor extends JFrame { @@ -29,17 +27,20 @@ public class FormTracktor extends JFrame { buttonCreate.addActionListener(e->{ Random rnd = new Random(); _tracktor = new DrawningTracktor(); + _tracktor.Init( rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)), rnd.nextInt(3,8) ); + _tracktor.SetPosition( rnd.nextInt(10, 100), rnd.nextInt(10, 100), pictureBox.getWidth(), pictureBox.getHeight() ); + speedLabel.setText("Скорость: " + _tracktor.getTracktor().getSpeed()); weightLabel.setText("Вес: " + _tracktor.getTracktor().getWeight()); colorLabel.setText("Цвет: " + String.format("%h",_tracktor.getTracktor().getBodyColor()));