Search lessons

Suggested searches

Browse

Car

public class Car {
    
    public String manufacturer;
    public String model;
    public int miles;
    public double maxSpeed;

    public Car(String manufacturer, String model, int miles, double maxSpeed) {
        this.manufacturer = manufacturer;
        this.model = model;
        this.miles = miles;
        this.maxSpeed = maxSpeed;
    }

    public void addMiles(int additionalMiles) {
        this.miles += additionalMiles;
    }

    public void printInfo() {
        System.out.println(manufacturer + " " + model + " driven for " + 
            miles + " with a max speed of " + maxSpeed + ".");
    }
}

Progress is available when JavaScript is enabled.

Manage progress

Progress is saved only in this browser. Export a copy to move it to another device.

Opening a lesson marks it complete on this browser. That records a visit, not understanding or a quiz score. Test yourself with the knowledge checks and labs. How progress works

Edit this lesson · View source