
public class Car {

    public static final double MAX_SPEED = 150.0;

    private final String make;
    
    private final int year;
    
    private double speed;

    public Car(String m, int y, double s) {
        this.make = m;
        this.year = y;
        this.speed = s;
    }

    public Car(String m, int y) {
        this.make = m;
        this.year = y;
        this.speed = 0;
    }

    public String toString() {
        return String.format("A %d %s that is going %.1f mph",
            this.year, this.make, this.speed);
    }

    public String getMake() {
        return this.make;
    }

    public int getYear() {
        return this.year;
    }

    public double getSpeed() {
        return this.speed;
    }

    public void accelerate() {
        this.speed += 5.0;

        if (this.speed > MAX_SPEED) {
            this.speed = MAX_SPEED;
        }
    }

    public void accelerate(double amount) {
        this.speed += amount;

        if (this.speed > MAX_SPEED) {
            this.speed = MAX_SPEED;
        }
    }

    public void brake() {
        this.speed -= 5.0;

        if (this.speed < 0.0) {
            this.speed = 0.0;
        }
    }

}
