package mv3302.sensor;

import simkit.smd.Mover;

/**
 * A simple constant rate sensor that detects objects within a maximum range
 * based on a mean time to detect. Inherits from AbstractSimpleSensor.
 */
public final class SimpleConstantRateSensor extends AbstractSimpleSensor {

    private double meanTimeToDetect;

    /**
     * Constructs a SimpleConstantRateSensor object with default values.
     */
    public SimpleConstantRateSensor() {
        super();
    }

    /**
     *
     * Constructs a SimpleConstantRateSensor object with the specified mover,
     * maximum range, and mean time to detect.
     *
     * @param mover the mover associated with the sensor
     * @param maxRange the maximum range of the sensor
     * @param meanTimeToDetect the mean time taken by the sensor to detect an
     * object
     */
    public SimpleConstantRateSensor(Mover mover, double maxRange, double meanTimeToDetect) {
        super(mover, maxRange);
        setMeanTimeToDetect(meanTimeToDetect);
    }

    /**
     *
     * Returns the mean time to detect an object.
     *
     * @return the mean time to detect an object
     */
    public double getMeanTimeToDetect() {
        return meanTimeToDetect;
    }

    /**
     *
     * Sets the mean time to detect an object.
     *
     * @param meanTimeToDetect the mean time to detect an object
     * @throws IllegalArgumentException if the meanTimeToDetect value is less
     * than 0.0
     */
    public void setMeanTimeToDetect(double meanTimeToDetect) {
        if (meanTimeToDetect < 0.0) {
            throw new IllegalArgumentException("meanTimeToDetect must be >= 0.0: " + meanTimeToDetect);
        }
        this.meanTimeToDetect = meanTimeToDetect;
    }
}