package ru.agolovin;

//Симулятор лифта

public class Elevator implements Runnable{

    private int maxFloor;
    private int height;
    private int speed;
    private int stopTime;

    private int currentFloor;

    public Elevator(int maxFloor, int height, int speed, int stopTime) {
        this.maxFloor = maxFloor;
        this.height = height;
        this.speed = speed;
        this.stopTime = stopTime;
    }


    @Override
    public void run() {

    }
}

@@ -34,16 +34,106 @@
  %D0%BB%D0%B8%D1%84%D1%82%D0%B0%0A%0A
+import java.util.concurrent.ConcurrentSkipListSet;%0Aimport java.util.concurrent.TimeUnit;%0A%0A
 public c
@@ -165,16 +165,17 @@
 Runnable
+ 
 %7B%0A%0A    p
@@ -185,33 +185,13 @@
 ate 
+f
 in
-t maxFloor;%0A    private
+al
  int
@@ -207,24 +207,30 @@
     private 
+final 
 int speed;%0A 
@@ -236,24 +236,30 @@
     private 
+final 
 int stopTime
@@ -260,16 +260,41 @@
 opTime;%0A
+    private int maxFloor;
 %0A    pri
@@ -315,16 +315,95 @@
 ntFloor;
+%0A    private boolean allowed;%0A    private ConcurrentSkipListSet%3CInteger%3E calls;
 %0A%0A    pu
@@ -603,50 +603,2059 @@
     
-%7D%0A%0A%0A    @Override%0A    public void run() %7B%0A
+    calls = new ConcurrentSkipListSet%3C%3E();%0A    %7D%0A%0A    private void init() %7B%0A        this.currentFloor = 1;%0A%0A    %7D%0A%0A    private int speedDelay() %7B%0A        return height / speed;%0A    %7D%0A%0A    @Override%0A    public void run() %7B%0A        do %7B%0A            move(targetFloor);%0A            try %7B%0A                Thread.sleep(200);%0A            %7D catch (InterruptedException e) %7B%0A                e.printStackTrace();%0A            %7D%0A%0A        %7D while (allowed);%0A    %7D%0A%0A    private void move(int targetFloor) %7B%0A        try %7B%0A            targetFloor--;%0A            if (targetFloor == 0) %7B%0A                this.allowed = false;%0A            %7D%0A            if (targetFloor == currentFloor) %7B%0A                turnDoor();%0A            %7D else %7B%0A                if (targetFloor %3E currentFloor) %7B%0A                    moveUP(targetFloor);%0A                    turnDoor();%0A                    this.currentFloor = targetFloor;%0A                %7D else %7B%0A                    moveDown(targetFloor);%0A                    turnDoor();%0A                    this.currentFloor = targetFloor;%0A                %7D%0A            %7D%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    private void moveDown(int targetFloor) throws InterruptedException %7B%0A        for (int i = currentFloor; i %3E targetFloor; i--) %7B%0A            messageCurrentFloor(i);%0A            TimeUnit.SECONDS.sleep(speedDelay());%0A        %7D%0A    %7D%0A%0A    private void moveUP(int targetFloor) throws InterruptedException %7B%0A        for (int i = currentFloor; i %3C targetFloor; i++) %7B%0A            TimeUnit.SECONDS.sleep(speedDelay());%0A            messageCurrentFloor(i);%0A        %7D%0A%0A    %7D%0A%0A    private void turnDoor() %7B%0A        try %7B%0A            System.out.println(%22%D0%9B%D0%B8%D1%84%D1%82 %D0%BE%D1%82%D0%BA%D1%80%D1%8B%D0%B2%D0%B0%D0%B5%D1%82 %D0%B4%D0%B2%D0%B5%D1%80%D0%B8%22);%0A            TimeUnit.SECONDS.sleep(stopTime);%0A            System.out.println(%22%D0%9B%D0%B8%D1%84%D1%82 %D0%B7%D0%B0%D0%BA%D1%80%D1%8B%D0%B2%D0%B0%D0%B5%D1%82 %D0%B4%D0%B2%D0%B5%D1%80%D0%B8%22);%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    private void messageCurrentFloor(int i) %7B%0A        System.out.println(String.format(%22%D0%9B%D0%B8%D1%84%D1%82 %D0%BF%D1%80%D0%BE%D0%B5%D1%85%D0%B0%D0%BB %25d %D1%8D%D1%82%D0%B0%D0%B6%22, i));
 %0A   

add additional test task in part6 chapter7 package2