/** A class to represent a Cat. */ public class Cat { // Field names duplicated in every type of animal. String name; String sound; // 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; this.sound = "meow"; // But this line okay -- it is specific to cats: this.clawSharpness = 0.9; // Kittens start out with sharp claws. } /** When the animal wants to bug a human, it says... * @return The sound of the animal, bugging its owner. */ public String speak() { return this.sound + ", " + this.sound + "."; } // 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"; } }