// This class is a subclass of the ball class
 // Notice use of super() to call the superclass constructor 
class ballInBox extends ball {
   // Inherits everything from ball class
 // additional attributes
   box myBox;
 ballInBox(float _x, float _y, float _r, color _c, box _b) {
   super(_x, _y, _r, _c);
   myBox = _b;
   } // ballInBox()
 // override the behavior of inherited bounce()
   void bounce() {
   if (x < radius) {
   x = radius;
   dx = -dx;
   }
 if (x > myBox.w-radius) {
   x = myBox.w-radius;
   dx = -dx;
   }
 if (y < radius) {
   y = radius;
   dy = -dy;
   }
 if (y > myBox.h - radius) {
   y = myBox.h-radius;
   dy = -dy;
   speed = speed*dampen;
   }
   } // bounce()
} // class ballInBox