L8.3: Getters & Setters - Car class

PHOTO EMBED

Wed Oct 18 2023 12:47:57 GMT+0000 (Coordinated Universal Time)

Saved by @testpro #java

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