Let’s write the code. Open your CodeHS editor and create a new file named Car.java . (Note: The main runner file is usually provided by CodeHS, so you only need to write the Car class).
Attempt to drive 1000 miles to ensure the car stops when empty.
// 3. Getters public String getModel() { return model; }
public void setYear(int year) { this.year = year; }
The constructor has the same name as the class ( Car ) and no return type. It sets the initial state of the object.