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