// Whale.java [dynamic] import java.util.*; public class Whale extends Mammal implements Swimmer, Jumper { int depth; int swam_distance; public Whale() { depth = 0; swam_distance = 0; } private void Propel() { swam_distance++; } // --- for Swimmer public void JumpInTheWater() { trace( "Whale.JumpInTheWater()" ); } public void Submerge() { trace( "Whale.Submerge()"); depth++; } public void MoveFin() { trace( "Whale.MoveFin()"); Propel(); } public void Rise() { trace( "Whale.Rise()");depth--; } public void JumpOutOfTheWater() { trace( "Whale.JumpOutOfTheWater()"); } // --- for Jumper public boolean CheckDistance(int x, int y) { trace( "Whale.CheckDistance()" ); return true; } public void SprintTo(int x, int y) { trace( "Whale.SprintTo()" ); } public void LiftOff(int alt) { trace( "Whale.LiftOff()" ); } public void Land() { trace( "Whale.Land()" ); } // ============== for Swimmer Swimmer$Ego $swimmer = new Swimmer$Ego( $shrink ); public void Swim(int miles, int depth) { if ( personifies( "Swimmer" ) ) $swimmer.Swim(this, miles, depth); } // ============== for Jumper Jumper$Ego $jumper = new Jumper$Ego( $shrink ); public void Jump(int x, int y, int alt) { if ( personifies( "Jumper" ) ) $jumper.Jump(this, x, y, alt); } }