package class3_1_Polymorphism; public class FlyingAnimal extends Animal { public double distanceUpMeters; /** * @param name display name of the flying animal */ public FlyingAnimal(String name) { super(name); } /** * Peforms very generic flying. * @ distance how far to fly up (meters) */ public void flyUp(double distance) { // most flying animals will probably want to // do this System.out.println("flap wings"); distanceUpMeters += distance; } /** * Converts flying animal to a string * -- including altitude * @return */ public String toString() { // return name+" "+location+" meters from start" // + " and " + distanceUpMeters + " meters up."; return super.toString() + " and " + formatter.format(distanceUpMeters) + " meters up."; } @Override public void speak() { } }