Question: create a new method with the name setSize to the Rectangle class that updates the width and height of a rectangle object that won't affect

create a new method with the name setSize to the Rectangle class that updates the width and height of a rectangle object that won't affect the top-left corner coordinates.and will be maintaining the same top-left corner coordinates.

create a new method with the name setSize to the Rectangle classthat updates the width and height of a rectangle object that won'taffect the top-left corner coordinates.and will be maintaining the same top-left corner

setValues(0,0,0,0); } * /** * Initialize rectangle data from coordinates of top-left corner and size. * @param left x-coordinate of top-left corner (left edge) of rectangle * @param top y-coordinate of top-left corner (top edge) of rectangle * @param width width of rectangle @param height height of rectangle */ public Rectangle(double left, double top, double width, double height) { setValues (left, top, width, height); } /** * Set rectangle data. * Used to update game entities that move and/or change size. * @param left x-coordinate of top-left corner (left edge) of rectangle * @param top y-coordinate of top-left corner (top edge) of rectangle * @param width width of rectangle * @param height height of rectangle */ public void setValues (double left, double top, double width, double height) { this. left = left; this.top top; this.width width; this.height = height; this.right = left + width; this.bottom - top + height; } /** * Update rectangle data. * Used for game entities that move. @param left x-coordinate of top-left corner (left edge) of rectangle * @param top y-coordinate of top-left corner (top edge) of rectangle } /** * Update rectangle data. * Used for game entities that move. * @param left x-coordinate of top-left corner (left edge) of rectangle * @param top y-coordinate of top-left corner (top edge) of rectangle public void setPosition(double left, double top) { setValues (left, top, this.width, this.height); } /** * Determine if this rectangle overlaps with other rectangle. @param other rectangle to check for overlap * @return true if this rectangle overlaps with other rectangle */ public boolean overlaps (Rectangle other) { boolean noOverlap = (other right

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!