1 class Dimension extends Object { 2 3 // Instance variables: 4 protected double width, height; 5 6 // Constructors: 7 public Dimension(double width, double height) { 8 setWidth(width); setHeight(height); 9 } 10 public Dimension() { } 11 12 // Encapsulate the instance variables: 13 public void setWidth(double width) { 14 this.width = width; 15 } 16 public void setHeight(double height) { 17 this.height = height; 18 } 19 public void setDimension(double width, double height) { 20 setWidth(width); setHeight(height); 21 } 22 public double getWidth() { 23 return width; 24 } 25 public double getHeight() { 26 return height; 27 } 28 29 }