public class Dimension extends Object { // Instance variables: protected double width, height; // Constructors: public Dimension(double width, double height) { setWidth(width); setHeight(height); } public Dimension(Dimension d) { setWidth(d.width); setHeight(d.height); } public Dimension() { } // Encapsulate the instance variables: public void setWidth(double width) { this.width = width; } public void setHeight(double height) { this.height = height; } public void setDimension(double width, double height) { setWidth(width); setHeight(height); } public void setDimension(Dimension d) { setWidth(d.width); setHeight(d.height); } public double getWidth() { return width; } public double getHeight() { return height; } public Dimension getDimension() { return new Dimension(width, height); } // Instance methods: public String toString() { return super.toString(); // to be overridden } }