5.6.7 Car Class Codehs May 2026

public void setYear(int year) { this.year = year; }

public void setModel(String model) { this.model = model; } 5.6.7 Car Class Codehs

public String getModel() { return model; } public void setYear(int year) { this

public String toString() { return year + " " + make + " " + model; } } Here’s the complete class (without a main method – CodeHS usually provides a separate tester file). 5.6.7 Car Class Codehs

// Setter for year public void setYear(int newYear) { year = newYear; } This makes it easy to print a readable representation of the car.

// Getter for year public int getYear() { return year; } These allow you to change the values after the object is created.