Переход на конструкторы
This commit is contained in:
parent
460a7750b1
commit
489964eb09
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11.0.5" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="openjdk-19" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/../../../ирино, не трогат/!/!/!/!/RPP/ProjectAircraftCarrierHard/out" />
|
<output url="file://$PROJECT_DIR$/../../../ирино, не трогат/!/!/!/!/RPP/ProjectAircraftCarrierHard/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -14,10 +14,9 @@ public class DrawingWarship {
|
|||||||
private final int _warshipWidth = 114;
|
private final int _warshipWidth = 114;
|
||||||
private final int _warshipHeight = 40;
|
private final int _warshipHeight = 40;
|
||||||
|
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public DrawingWarship(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Warship = new EntityWarship();
|
Warship = new EntityWarship(speed, weight, bodyColor);
|
||||||
Warship.Init(speed, weight, bodyColor);
|
|
||||||
Blocks = new DrawingBlocks();
|
Blocks = new DrawingBlocks();
|
||||||
Blocks.blockDirection = BlockRandom();
|
Blocks.blockDirection = BlockRandom();
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@ public class EntityWarship {
|
|||||||
public Color GetBodyColor (){return BodyColor;}
|
public Color GetBodyColor (){return BodyColor;}
|
||||||
|
|
||||||
public float Step;
|
public float Step;
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public EntityWarship(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
Speed = speed <= 0 ? rnd.nextInt(100) + 50 : speed;
|
Speed = speed <= 0 ? rnd.nextInt(50, 150) : speed;
|
||||||
Weight = weight <= 0 ? rnd.nextInt(30)+40 : weight;
|
Weight = weight <= 0 ? rnd.nextInt(40, 70) : weight;
|
||||||
BodyColor= bodyColor;
|
BodyColor= bodyColor;
|
||||||
Step = Speed * 100 / Weight;
|
Step = Speed * 100 / Weight;
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,7 @@ public class FormWarship extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
_warship = new DrawingWarship();
|
_warship = new DrawingWarship(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||||
_warship.Init(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)));
|
||||||
_warship.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10, drawPanel.getWidth(), drawPanel.getHeight());
|
_warship.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10, drawPanel.getWidth(), drawPanel.getHeight());
|
||||||
toolBarLabelSpeed.setText("Color: " + _warship.GetWarship().GetSpeed() + " ");
|
toolBarLabelSpeed.setText("Color: " + _warship.GetWarship().GetSpeed() + " ");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user