class Cat extends Animal { // A Cat "is-a" Animal. // The fields `name`, `sound` are inherited from Animal. // A field specific to cats, not shared by all Animals: double clawSharpness; // 0.0 represents dull; 1.0 is razor-sharp. /** Constructor * @param _name, the cat's name. */ Cat( String _name ) { this.name = _name; // BAD -- this.sound = "meow"; // we're duplicating code from Animal constructor! // But this line okay -- it is specific to cats: this.clawSharpness = 0.9; // Kittens start out with sharp claws. } // A method specific to cats, not shared by all Animals: /** What happens, when a cat pounces. * @return The sound of this cat pouncing. */ String pounce() { // Every time they pounce, the claws get 10% closer to perfect sharpness: this.clawSharpness += 0.1*(1.0-this.clawSharpness); return "whoooomf"; } }