ElectricCar + car + Vehicle

This commit is contained in:
Matin
2026-04-27 12:00:55 +04:30
parent e8aedb8354
commit 78137e3270
3 changed files with 90 additions and 2 deletions
+28 -1
View File
@@ -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(