package tutorial.jdo; import java.util.*; import javax.jdo.*; /** * A snake is an animal that is likely to eat rabbits. * This class will be used in Chapter V. */ public class Snake extends Animal { // the resale price of a snake public static final float RESALE_PRICE = 150.0f; // member variable declarations go here private short length = 0; /** * Constructor. * * @param name the name of this snake * @param feet the length of the snake, in feet */ public Snake(String name, short feet) { super(name, RESALE_PRICE); length = feet; } public String toString(boolean detailed) { StringBuffer buf = new StringBuffer(1024); buf.append("Snake ").append(getName()); if (detailed) { buf.append(" (").append(length).append(" feet long) sells for "); buf.append(getPrice()).append(" dollars."); } return buf.toString(); } }