package org.academiadecodigo.carcrash.cars;

import org.academiadecodigo.carcrash.field.Position;

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

public class Ferrari extends Car {
    private double breakdownRoll;

    public Ferrari() {
        super(CarType.FERRARI, new Position());
        this.breakdownRoll = 0.001;
        setMaxSpeed(4);
    }

    @Override
    public void move() {
        super.move();
        if (isCrashed()) { return; }
        if (Math.random() < breakdownRoll) {
            System.out.println(this.getClass().getSimpleName() + " has crashed on its own.");
            crash();
        } else {
            this.breakdownRoll *= 1.01;
        }
    }
}
