Выполненная усложненная лабораторная работа №3(точно)

This commit is contained in:
AnnZhimol 2022-10-29 19:59:06 +04:00
parent 13cead9f97
commit 2321881dd1
3 changed files with 62 additions and 60 deletions

View File

@ -28,7 +28,6 @@ public class CreaterGeneric<T extends EntityWarship, U extends IDrawingObjectBlo
public DrawingWarship NewWarshipCreating()
{
Random rand=new Random();
DrawingWarship finalWarship;
T warship = (T)Warships[rand.nextInt(WarshipsCount)];
U block = (U)Blocks[rand.nextInt(BlocksCount)];
if(warship instanceof EntityAdvancedWarship){

View File

@ -26,7 +26,7 @@
<grid id="e26e" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title="Тип корабля:"/>
@ -91,43 +91,6 @@
</component>
</children>
</grid>
<grid id="fc97" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title="Улучшения:"/>
<children>
<component id="fca4f" class="javax.swing.JCheckBox" binding="MissileCheckBox">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<label value="Боевые ракеты"/>
<text value="Боевые ракеты"/>
</properties>
</component>
<component id="a7f46" class="javax.swing.JCheckBox" binding="AntennaCheckBox">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<label value="Антенна"/>
<text value="Антенна"/>
</properties>
</component>
<component id="632da" class="javax.swing.JCheckBox" binding="HelipadCheckBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<label value="Вертолетная площадка"/>
<text value="Вертолетная площадка"/>
</properties>
</component>
</children>
</grid>
<grid id="d3b9d" binding="CargoPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
@ -230,6 +193,43 @@
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="fc97" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title="Улучшения:"/>
<children>
<component id="fca4f" class="javax.swing.JCheckBox" binding="MissileCheckBox">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<label value="Боевые ракеты"/>
<text value="Боевые ракеты"/>
</properties>
</component>
<component id="a7f46" class="javax.swing.JCheckBox" binding="AntennaCheckBox">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<label value="Антенна"/>
<text value="Антенна"/>
</properties>
</component>
<component id="632da" class="javax.swing.JCheckBox" binding="HelipadCheckBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<label value="Вертолетная площадка"/>
<text value="Вертолетная площадка"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<hspacer id="ca2ae">

View File

@ -1,5 +1,7 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
public class FormCreater extends JDialog{
@ -92,29 +94,30 @@ public class FormCreater extends JDialog{
createrGeneric.AddBlock(fblock);
});
BasicRadioButton.addActionListener(e -> {
Color color=JColorChooser.showDialog(this,"Выберите цвет корпуса корабля",Color.WHITE);
if(Integer.parseInt(SpeedTextField.getText())==0 || Integer.parseInt(WeightTextField.getText())==0 || color==null){
return;
}
createrGeneric.AddWarship(new EntityWarship(Integer.parseInt(SpeedTextField.getText()),Integer.parseInt(WeightTextField.getText()),color));
});
AdvancedRadioButton.addActionListener(e -> {
Color color1=JColorChooser.showDialog(this,"Выберите цвет корпуса корабля",Color.WHITE);
if(Integer.parseInt(SpeedTextField.getText())==0 || Integer.parseInt(WeightTextField.getText())==0 || color1==null){
return;
}
Color color2=JColorChooser.showDialog(this,"Выберите цвет модификаций корабля",Color.WHITE);
if(color2==null){
return;
}
createrGeneric.AddWarship(new EntityAdvancedWarship(Integer.parseInt(SpeedTextField.getText()),Integer.parseInt(WeightTextField.getText()),
color1,color2,HelipadCheckBox.isSelected(),AntennaCheckBox.isSelected(),MissileCheckBox.isSelected()));
});
ShowWarshipButton.addActionListener(e -> {
Random rand=new Random();
if (BasicRadioButton.isSelected()) {
Color color=JColorChooser.showDialog(this,"Выберите цвет корпуса корабля",Color.WHITE);
if(Integer.parseInt(SpeedTextField.getText())==0 || Integer.parseInt(WeightTextField.getText())==0 || color==null){
return;
}
createrGeneric.AddWarship(new EntityWarship(Integer.parseInt(SpeedTextField.getText()),Integer.parseInt(WeightTextField.getText()),color));
_warship=createrGeneric.NewWarshipCreating();
}
if (AdvancedRadioButton.isSelected()){
Color color1=JColorChooser.showDialog(this,"Выберите цвет корпуса корабля",Color.WHITE);
if(Integer.parseInt(SpeedTextField.getText())==0 || Integer.parseInt(WeightTextField.getText())==0 || color1==null){
return;
}
Color color2=JColorChooser.showDialog(this,"Выберите цвет модификаций корабля",Color.WHITE);
if(color2==null){
return;
}
createrGeneric.AddWarship(new EntityAdvancedWarship(Integer.parseInt(SpeedTextField.getText()),Integer.parseInt(WeightTextField.getText()),
color1,color2,HelipadCheckBox.isSelected(),AntennaCheckBox.isSelected(),MissileCheckBox.isSelected()));
_warship=createrGeneric.NewWarshipCreating();
}
_warship=createrGeneric.NewWarshipCreating();
_warship.SetPosition(rand.nextInt(100),rand.nextInt(100),getWidth(),getHeight());
repaint();
});