Untitled

mail@pastecode.io avatar
unknown
java
9 days ago
1.1 kB
4
Indexable
Never
class Ride {
    public static final int speedLimit = 80;
    public double initial_speed;
    public double acceleration;
    public int baseFine;
    public int fineRate;

    double getHighestAccelerationTime() {
        return (80 - initial_speed) / acceleration;
    }

    double calculateFine(int hour) {
        double temp = hour - getHighestAccelerationTime();
        return baseFine + (fineRate * temp);
    }
}

class Bike extends Ride {
    Bike() {
        initial_speed = 20;
        acceleration = 2;
        baseFine = 50;
        fineRate = 100;
    }
}

class Car extends Ride {
    Car(){
        initial_speed = 40;
        acceleration = 10;
        baseFine = 100;
        fineRate = 150;
    }
}

class microbus extends Ride {
    microbus() {
        initial_speed = 15;
        acceleration = 5;
    }

    double calculateFine(int hour) {
        return 3000;
    }
}

public class Uthao {
    public static void main(String[] args) {
        Ride car = new Car();
        System.out.println(car.calculateFine(10));
    }
}
Leave a Comment