From 63c9b86d3e1ef15f652bb9f54a9c91666e9e005a Mon Sep 17 00:00:00 2001 From: insideq Date: Sat, 8 Jun 2024 11:25:24 +0400 Subject: [PATCH] revert 0386119bccd4aeac47946be033865d2a3dd74a9d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert Лабораторная работа №3 добавил кнопку --- .../src/FormAdditionalCollection.java | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/ProjectExcavator/src/FormAdditionalCollection.java b/ProjectExcavator/src/FormAdditionalCollection.java index 5fe5676..7b419ed 100644 --- a/ProjectExcavator/src/FormAdditionalCollection.java +++ b/ProjectExcavator/src/FormAdditionalCollection.java @@ -22,8 +22,7 @@ public class FormAdditionalCollection extends JFrame { private CanvasExcavator canvasExc = new CanvasExcavator(); private AdditionalCollections additionalCollection = null; private Random random = new Random(); - private JButton buttonCreate = new JButton("Создать"); - private JButton buttonAdd = new JButton("Добавить"); + private JButton buttonGenerate = new JButton("Создать"); private JList listEntity = new JList(); private JList listRollers = new JList(); public FormAdditionalCollection() { @@ -32,15 +31,22 @@ public class FormAdditionalCollection extends JFrame { additionalCollection = new AdditionalCollections(3, (Class) EntityBulldozer.class, (Class) IDifferentRollers.class); AddEntities(); AddRollers(); - - buttonCreate.addActionListener(new ActionListener() { + buttonGenerate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + drawingBulldozer = additionalCollection.CreateAdditionalCollectionBulldozer(); drawingBulldozer.SetPictureSize(getWidth(), getHeight()); - drawingBulldozer.SetPosition(50, 50); + drawingBulldozer.SetPosition(50,50); canvasExc._drawingBulldozer = drawingBulldozer; canvasExc.repaint(); + DrawingBulldozer copyBulldozer; + if (drawingBulldozer instanceof DrawingExcavator) + copyBulldozer = new DrawingExcavator((EntityExcavator) drawingBulldozer.EntityBulldozer, drawingBulldozer.drawingRollers); + else + copyBulldozer = new DrawingBulldozer(drawingBulldozer.EntityBulldozer, drawingBulldozer.drawingRollers); + company._collection.Insert(copyBulldozer); + FormBulldozerCollection.canvasShow(); String[] data1 = new String[additionalCollection.CountEntities]; for (int i = 0; i < additionalCollection.CountEntities; i++) { @@ -56,25 +62,8 @@ public class FormAdditionalCollection extends JFrame { listRollers.setListData(data2); } }); - - buttonAdd.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (drawingBulldozer != null) { - DrawingBulldozer copyBulldozer; - if (drawingBulldozer instanceof DrawingExcavator) - copyBulldozer = new DrawingExcavator((EntityExcavator) drawingBulldozer.EntityBulldozer, drawingBulldozer.drawingRollers); - else - copyBulldozer = new DrawingBulldozer(drawingBulldozer.EntityBulldozer, drawingBulldozer.drawingRollers); - company._collection.Insert(copyBulldozer); - FormBulldozerCollection.canvasShow(); - } - } - }); - buttonCreate.setBounds(300, 10, 100, 50); - buttonAdd.setBounds(450, 10, 100, 50); - add(buttonCreate); - add(buttonAdd); + buttonGenerate.setBounds(450, 10, 100, 50); + add(buttonGenerate); listEntity.setBounds(10,200,300,60); listRollers.setBounds(320,200,300,60); add(listEntity); @@ -92,10 +81,10 @@ public class FormAdditionalCollection extends JFrame { private String ToString(IDifferentRollers rollers) { if (rollers == null || rollers.getRollersCount() == null) return "Dont have rollers"; - String str = "Rollers "; + String str = "Deck "; if (rollers instanceof DrawingRollersCross) str += "Type Cross "; else if (rollers instanceof DrawingRollersPlus) str += "Type Plus "; - else str += "Type Star "; + else str += "Type 3 "; str += rollers.getRollersCount().toString(); return str; }