package org.academiadecodigo.carcrash.cars;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public class Ferrari extends Car {
    private double breakdownChance;
    private int steps;

    public Ferrari() {
        super(Brand.FERRARI);
        this.breakdownChance = 0.0001;
        this.steps = 0;
    }

    @Override
    public void move() {
        if (isCrashed()) { return; }

        if (Math.random() < this.breakdownChance) { crash(); return; }
        this.breakdownChance *= 1.01;

        if (this.steps % 3 == 0) {
            setDirection(getNewOrientation());
        }

        setDirection(getPos().move(getOrientation(),1));
        this.steps++;
    }
}
