ElectricCar + car + Vehicle
This commit is contained in:
@@ -21,12 +21,39 @@ public abstract class Vehicle {
|
||||
}
|
||||
|
||||
// TODO: Create getters for all fields
|
||||
|
||||
public String GetBrand()
|
||||
{
|
||||
return this.brand ;
|
||||
}
|
||||
public String GetModel()
|
||||
{
|
||||
return this.model ;
|
||||
}
|
||||
public int GetYear()
|
||||
{
|
||||
return this.year ;
|
||||
}
|
||||
public double GetMileage()
|
||||
{
|
||||
return this.mileage ;
|
||||
}
|
||||
// TODO: Implement addMileage(double km)
|
||||
public void AddMileage(double km)
|
||||
{
|
||||
if (km < 0 )
|
||||
{
|
||||
System.out.println("error !") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mileage = this.mileage + km ;
|
||||
}
|
||||
}
|
||||
// If km is negative → print error
|
||||
// Otherwise increase mileage
|
||||
|
||||
// TODO: Declare abstract method getEnergyType()
|
||||
public abstract String getEnergyType();
|
||||
|
||||
public void basicInfo() {
|
||||
System.out.println(
|
||||
|
||||
Reference in New Issue
Block a user