Переход на конструкторы
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"?>
|
||||
<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" />
|
||||
</component>
|
||||
</project>
|
@ -14,10 +14,9 @@ public class DrawingWarship {
|
||||
private final int _warshipWidth = 114;
|
||||
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.Init(speed, weight, bodyColor);
|
||||
Warship = new EntityWarship(speed, weight, bodyColor);
|
||||
Blocks = new DrawingBlocks();
|
||||
Blocks.blockDirection = BlockRandom();
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ public class EntityWarship {
|
||||
public Color GetBodyColor (){return BodyColor;}
|
||||
|
||||
public float Step;
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityWarship(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Speed = speed <= 0 ? rnd.nextInt(100) + 50 : speed;
|
||||
Weight = weight <= 0 ? rnd.nextInt(30)+40 : weight;
|
||||
Speed = speed <= 0 ? rnd.nextInt(50, 150) : speed;
|
||||
Weight = weight <= 0 ? rnd.nextInt(40, 70) : weight;
|
||||
BodyColor= bodyColor;
|
||||
Step = Speed * 100 / Weight;
|
||||
}
|
||||
|
@ -50,8 +50,7 @@ public class FormWarship extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Random rnd = new Random();
|
||||
_warship = new DrawingWarship();
|
||||
_warship.Init(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||
_warship = new DrawingWarship(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||
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());
|
||||
toolBarLabelSpeed.setText("Color: " + _warship.GetWarship().GetSpeed() + " ");
|
||||
|
Loading…
x
Reference in New Issue
Block a user