<commit_before>import carControl.Control
import carControl.RouteExecutor
import carControl.RouteExecutorImpl.MoveDirection

/**
 * Created by user on 7/27/16.
 */
class Car constructor(routeExecutor: RouteExecutor, controller: Control) {


    val velocityMove = 0.1
    val velocityRotation = 5.0

    //position
    var x: Double
    var y: Double
    var angle: Double

    var moveDirection: MoveDirection = MoveDirection.STOP

    val routeExecutor: RouteExecutor
    val controller: Control

    init {
        this.routeExecutor = routeExecutor
        this.controller = controller
        this.x = 0.0
        this.y = 0.0
        this.angle = 0.0
    }

    fun stopCar() {
        move(MoveDirection.STOP, 0.0, {})
    }

    fun refreshLocation(delta: Int) {
        val deltaSeconds = delta.toDouble() / 1000
        when (moveDirection) {
            MoveDirection.FORWARD -> {
                this.x += this.velocityMove * deltaSeconds * Math.cos(this.angle * Math.PI / 180);
                this.y += this.velocityMove * deltaSeconds * Math.sin(this.angle * Math.PI / 180);
            }
            MoveDirection.BACKWARD -> {
                this.x -= this.velocityMove * deltaSeconds * Math.cos(this.angle * Math.PI / 180);
                this.y -= this.velocityMove * deltaSeconds * Math.sin(this.angle * Math.PI / 180);
            }
            MoveDirection.LEFT -> this.angle += velocityRotation * deltaSeconds
            MoveDirection.RIGHT -> this.angle -= velocityRotation * deltaSeconds
            else -> {

            }
        }
        println("x=$x; y=$y; angle=$angle")
    }

    fun routeDone() {
        controller.stopCar()
    }

    fun move(moveDirection: MoveDirection, value: Double, callBack: () -> Unit) {
        //value - angle for rotation command and distance for forward/backward command
        this.moveDirection = moveDirection
        when (moveDirection) {
            MoveDirection.STOP -> controller.stopCar()
            MoveDirection.FORWARD -> controller.moveCarForward()
            MoveDirection.BACKWARD -> controller.moveCarBackward()
            MoveDirection.LEFT -> controller.moveCarLeft()
            MoveDirection.RIGHT -> controller.moveCarRight()
        }
        if (moveDirection != MoveDirection.STOP) {
            if (moveDirection == MoveDirection.FORWARD || moveDirection == MoveDirection.BACKWARD) {
                controller.delay(getTimeForMoving(value, velocityMove), callBack)<commit_msg>commented coordinate print<commit_after>import carControl.Control
import carControl.RouteExecutor
import carControl.RouteExecutorImpl.MoveDirection

/**
 * Created by user on 7/27/16.
 */
class Car constructor(routeExecutor: RouteExecutor, controller: Control) {


    val velocityMove = 0.1
    val velocityRotation = 5.0

    //position
    var x: Double
    var y: Double
    var angle: Double

    var moveDirection: MoveDirection = MoveDirection.STOP

    val routeExecutor: RouteExecutor
    val controller: Control

    init {
        this.routeExecutor = routeExecutor
        this.controller = controller
        this.x = 0.0
        this.y = 0.0
        this.angle = 0.0
    }

    fun stopCar() {
        move(MoveDirection.STOP, 0.0, {})
    }

    fun refreshLocation(delta: Int) {
        val deltaSeconds = delta.toDouble() / 1000
        when (moveDirection) {
            MoveDirection.FORWARD -> {
                this.x += this.velocityMove * deltaSeconds * Math.cos(this.angle * Math.PI / 180);
                this.y += this.velocityMove * deltaSeconds * Math.sin(this.angle * Math.PI / 180);
            }
            MoveDirection.BACKWARD -> {
                this.x -= this.velocityMove * deltaSeconds * Math.cos(this.angle * Math.PI / 180);
                this.y -= this.velocityMove * deltaSeconds * Math.sin(this.angle * Math.PI / 180);
            }
            MoveDirection.LEFT -> this.angle += velocityRotation * deltaSeconds
            MoveDirection.RIGHT -> this.angle -= velocityRotation * deltaSeconds
            else -> {

            }
        }
//        println("x=$x; y=$y; angle=$angle")
    }

    fun routeDone() {
        controller.stopCar()
    }

    fun move(moveDirection: MoveDirection, value: Double, callBack: () -> Unit) {
        //value - angle for rotation command and distance for forward/backward command
        this.moveDirection = moveDirection
        when (moveDirection) {
            MoveDirection.STOP -> controller.stopCar()
            MoveDirection.FORWARD -> controller.moveCarForward()
            MoveDirection.BACKWARD -> controller.moveCarBackward()
            MoveDirection.LEFT -> controller.moveCarLeft()
            MoveDirection.RIGHT -> controller.moveCarRight()
        }
        if (moveDirection != MoveDirection.STOP) {
            if (moveDirection == MoveDirection.FORWARD || moveDirection == MoveDirection.BACKWARD) {
                controller.delay(getTimeForMoving(value, velocityMove), callBack)
{'fraction_non_alphanumeric': 0.1034413362849668, 'fraction_numerical': 0.013282350573556048, 'mean_word_length': 2.1797824696097248, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2201053', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1273, 'n_words': 301}