L8.3: Getters & Setters - Car class

PHOTO EMBED

Fri Jun 02 2023 11:38:47 GMT+0000 (Coordinated Universal Time)

Saved by @TestProSupport

public class Car {

    private int odometer = 0;
    private int productionYear = 0;

    public void setProductionYear(int year){
        productionYear = year;
    }
    
    public int getProductionYear (){
        return  productionYear;
    }

    public void drive( int miles) {
        System.out.println("Car drove " + miles + " miles");
        odometer = odometer + miles;
    }

    public String returnCarModel() {
        return "Car model is unknown";
    }
}
content_copyCOPY