override interface variable java code example
Example: override interface method with different parameters 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;
}
}