Лабораторная работа №3
This commit is contained in:
parent
0a53208d5e
commit
9a08a6c0f0
@ -11,6 +11,7 @@ import java.awt.*;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
public class DrawingWarship extends JPanel {
|
public class DrawingWarship extends JPanel {
|
||||||
|
|
||||||
public IDrawingBlocks drawingBlocks;
|
public IDrawingBlocks drawingBlocks;
|
||||||
public Entities.EntityWarship EntityWarship;
|
public Entities.EntityWarship EntityWarship;
|
||||||
public Integer _pictureWidth;
|
public Integer _pictureWidth;
|
||||||
|
@ -23,6 +23,7 @@ public class FormAdditionalCollection extends JFrame {
|
|||||||
private AdditionalCollections<EntityWarship, IDrawingBlocks> additionalCollection = null;
|
private AdditionalCollections<EntityWarship, IDrawingBlocks> additionalCollection = null;
|
||||||
private Random random = new Random();
|
private Random random = new Random();
|
||||||
private JButton buttonGenerate = new JButton("Создать");
|
private JButton buttonGenerate = new JButton("Создать");
|
||||||
|
private JButton buttonAdd = new JButton("Добавить");
|
||||||
private JList<String> listEntity = new JList<String>();
|
private JList<String> listEntity = new JList<String>();
|
||||||
private JList<String> listBlocks = new JList<String>();
|
private JList<String> listBlocks = new JList<String>();
|
||||||
public FormAdditionalCollection() {
|
public FormAdditionalCollection() {
|
||||||
@ -34,20 +35,11 @@ public class FormAdditionalCollection extends JFrame {
|
|||||||
buttonGenerate.addActionListener(new ActionListener() {
|
buttonGenerate.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
drawingWarship = additionalCollection.CreateAdditionalCollectionWarship();
|
drawingWarship = additionalCollection.CreateAdditionalCollectionWarship();
|
||||||
drawingWarship.SetPictureSize(getWidth(), getHeight());
|
drawingWarship.SetPictureSize(getWidth(), getHeight());
|
||||||
drawingWarship.SetPosition(50,50);
|
drawingWarship.SetPosition(50,50);
|
||||||
canvasBattleship._drawingWarship = drawingWarship;
|
canvasBattleship._drawingWarship = drawingWarship;
|
||||||
canvasBattleship.repaint();
|
canvasBattleship.repaint();
|
||||||
DrawingWarship copyWarship;
|
|
||||||
if (drawingWarship instanceof DrawingBattleship)
|
|
||||||
copyWarship = new DrawingBattleship((EntityBattleship) drawingWarship.EntityWarship, drawingWarship.drawingBlocks);
|
|
||||||
else
|
|
||||||
copyWarship = new DrawingWarship(drawingWarship.EntityWarship, drawingWarship.drawingBlocks);
|
|
||||||
company._collection.Insert(copyWarship);
|
|
||||||
FormWarshipCollection.canvasShow();
|
|
||||||
|
|
||||||
String[] data1 = new String[additionalCollection.CountEntities];
|
String[] data1 = new String[additionalCollection.CountEntities];
|
||||||
for (int i = 0; i < additionalCollection.CountEntities; i++) {
|
for (int i = 0; i < additionalCollection.CountEntities; i++) {
|
||||||
EntityWarship entity = additionalCollection._collectionEntity[i];
|
EntityWarship entity = additionalCollection._collectionEntity[i];
|
||||||
@ -62,8 +54,24 @@ public class FormAdditionalCollection extends JFrame {
|
|||||||
listBlocks.setListData(data2);
|
listBlocks.setListData(data2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
buttonAdd.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (drawingWarship != null) {
|
||||||
|
DrawingWarship copyWarship;
|
||||||
|
if (drawingWarship instanceof DrawingBattleship)
|
||||||
|
copyWarship = new DrawingBattleship((EntityBattleship) drawingWarship.EntityWarship, drawingWarship.drawingBlocks);
|
||||||
|
else
|
||||||
|
copyWarship = new DrawingWarship(drawingWarship.EntityWarship, drawingWarship.drawingBlocks);
|
||||||
|
company._collection.Insert(copyWarship);
|
||||||
|
FormWarshipCollection.canvasShow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
buttonGenerate.setBounds(450, 10, 100, 50);
|
buttonGenerate.setBounds(450, 10, 100, 50);
|
||||||
|
buttonAdd.setBounds(450, 70, 100, 50);
|
||||||
add(buttonGenerate);
|
add(buttonGenerate);
|
||||||
|
add(buttonAdd);
|
||||||
listEntity.setBounds(10,200,300,60);
|
listEntity.setBounds(10,200,300,60);
|
||||||
listBlocks.setBounds(320,200,300,60);
|
listBlocks.setBounds(320,200,300,60);
|
||||||
add(listEntity);
|
add(listEntity);
|
||||||
@ -82,8 +90,8 @@ public class FormAdditionalCollection extends JFrame {
|
|||||||
if (blocks == null || blocks.getNumBlocks() == null)
|
if (blocks == null || blocks.getNumBlocks() == null)
|
||||||
return "Не имеет блоки";
|
return "Не имеет блоки";
|
||||||
String str = "Blocks ";
|
String str = "Blocks ";
|
||||||
if (blocks instanceof DrawingBlocksType1) str += "Type 1 ";
|
if (blocks instanceof DrawingBlocksType1) str += "Тип 1 ";
|
||||||
else if (blocks instanceof DrawingBlocksType2) str += "Type 2 ";
|
else if (blocks instanceof DrawingBlocksType2) str += "Тип 2 ";
|
||||||
else str += "Type Blocks ";
|
else str += "Type Blocks ";
|
||||||
str += blocks.getNumBlocks().toString();
|
str += blocks.getNumBlocks().toString();
|
||||||
return str;
|
return str;
|
||||||
|
@ -149,6 +149,7 @@ public class FormWarshipCollection extends JFrame{
|
|||||||
}
|
}
|
||||||
FormBattleship form = new FormBattleship("Линкор", new Dimension(900,565));
|
FormBattleship form = new FormBattleship("Линкор", new Dimension(900,565));
|
||||||
form.Init(warship);
|
form.Init(warship);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user