/* SimpleSubclasses/Animal.java A very simple class, with three fields: weight x, y To serve as superclass for various animals, so this has common fields and methods. */ public class Animal { // instance variables that all animals have double weight; int x, y; // constructors Animal () { // create with defaults provided weight = 0.0; x = 0; y = 0; } ////////////////////////////////////////////////////////////////////// // a default move method for all animals public void move () { System.out.printf( "Animal at x=%d, y=%d moving...\n", x, y ); } public void printSelf () { System.out.printf( "Animal x=%d, y=%d, weight = %.2f\n", x, y, weight ); } ///////////////////////////////////////////////////////////////////////////////// // accessors (getters/setters) public double getWeight () { return weight; } public void setWeight ( double wt ) { weight = wt; } public int getX () { return x; } public void setX ( int i ) { x = i; } public int getY () { return y; } public void setY ( int i ) { y = i; } }