implement todos in vehicle.java
This commit is contained in:
@@ -20,14 +20,37 @@ public abstract class Vehicle {
|
||||
this.mileage = mileage;
|
||||
}
|
||||
|
||||
public String getBrand() {
|
||||
return brand;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public double getMileage() {
|
||||
return mileage;
|
||||
}
|
||||
|
||||
// TODO: Create getters for all fields
|
||||
|
||||
public void addMileage(double km) {
|
||||
if (km < 0) {
|
||||
System.out.println("error");
|
||||
return;
|
||||
}
|
||||
this.mileage += km;
|
||||
}
|
||||
// TODO: Implement addMileage(double km)
|
||||
// If km is negative → print error
|
||||
// Otherwise increase mileage
|
||||
|
||||
public abstract String getEnergyType();
|
||||
// TODO: Declare abstract method getEnergyType()
|
||||
|
||||
public void basicInfo() {
|
||||
System.out.println(
|
||||
year + " " + brand + " " + model +
|
||||
|
||||
Reference in New Issue
Block a user