java-training/src/Automobile.java
<reponame>kaushalpranav/python-ds-trainingpublic class Automobile {
    // static variables are tied to class and not to an instance
    public static String currentPolicy = "BS_V";

    // always make fields private
    // and use getters and setters to access them from outside
    private int amountOfFuel;
    private int speed;

    // getter for amountOfFuel
    public int getAmountOfFuel() {
        return amountOfFuel;
    }

    // setter for amountOfFuel
    public void setAmountOfFuel(int amountOfFuel) {
        this.amountOfFuel = amountOfFuel;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    // an empty constructor
    public Automobile() {

    }

    // a constructor with parameters
    public Automobile(int amountOfFuel, int speed) {
        this.amountOfFuel = amountOfFuel;
        this.speed = speed;
    }

    // a method on the Automobile class
    public void accelerate(int speedToIncrease) {
        this.speed += speedToIncrease;
    }
}
