Add the following method to your Rectangle class: public boolean contains(Rectangle rect) Returns whether the given other rectangle lies entirely within the bounds of this rectangle. (You don't need to write the class header or declare the fields; assume that this is already done for you. Just write your methods' complete code in the box provided.) See previous exercises for a description of the Rectangle and Point classes and their public members.

Respuesta :

Answer:

Explanation:

The code is not provided in the question but can be easily found online. The code is written in Java and the Rectangle class contains the following variables for the Rectangle object

   double x;

   double y;

   double width;

   double height;

The x and y represent the starting positions and then the width and height are added to these starting positions to indicate the endpoints. Ultimately, these four points create the rectangle. The following method detects if these points from the rectangle passed as an argument are within the rectangle in question

public boolean contains (Rectangle r) {

   return x < r.x + r.width && x + width > r.x && y < r.y + r.height && y + height > r.y;

}

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE