java override method from abstract class code example
Example: override abstract method java
public interface Order
{
public boolean greaterThan(Order other);
}
public class AirCraft implements Order
{
private String make;
private int numSeats;
public AirCraft(String make, int numSeats)
{
this.make = make;
this.numSeats = numSeats;
}
public String getMake()
{
return make;
}
public int getNumSeats()
{
return numSeats;
}
@Override
public boolean greaterThan(Order other)
{
AirCraft x = (AirCraft)other;
return getNumSeats() > x.getNumSeats();
}
public String toString()
{
return make + " -> " + numSeats;
}
}