Bondarenko M.S. Lab Work 2 #2

Closed
maxnes3 wants to merge 10 commits from LabWork_02 into LabWork_01
3 changed files with 4 additions and 6 deletions
Showing only changes of commit 1c30871417 - Show all commits

View File

@ -16,10 +16,9 @@ public class DrawingShip extends JPanel {
private DrawDeck dd = new DrawDeck();
//Инициализация
public void Init(int speed, float weight, Color bodyColor)
public DrawingShip(int speed, float weight, Color bodyColor)
{
warmlyShip = new EntityWarmlyShip();
warmlyShip.Init(speed, weight, bodyColor);
warmlyShip = new EntityWarmlyShip(speed, weight, bodyColor);
Random random = new Random();
dd.SetDeckCount(random.nextInt(1, 4));
}

View File

@ -8,7 +8,7 @@ public class EntityWarmlyShip {
private float Step; //Шаг при перемещении
//Инициализация
public void Init(int speed, float weight, Color bodyColor)
public EntityWarmlyShip(int speed, float weight, Color bodyColor)
{
Random random = new Random();
Speed = speed <= 0 ? random.nextInt(50, 150) : speed;

View File

@ -83,8 +83,7 @@ public class FormShip extends JFrame{
@Override
public void actionPerformed(ActionEvent e) {
Random random = new Random();
ship = new DrawingShip();
ship.Init(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)));
ship = new DrawingShip(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)));
ship.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100), GraphicsOutput.getWidth(), GraphicsOutput.getHeight());
JLabelSpeed.setText("орость: " + ship.GetWarmlyShip().GetSpeed() + " ");
JLabelWeight.setText("Вес: " + ship.GetWarmlyShip().GetWeight() + " ");