Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Java to finish the code, thank! This is similar to the exercise that was discussed in the lectures. However, you need to define

image text in transcribed

Please use Java to finish the code, thank!

This is similar to the exercise that was discussed in the lectures. However, you need to define two methods, namely, contains and touches, that have slightly different meanings. Please see the diagrams. Define the Rectangle class that contains: Double data fields named xpos, ypos (that specify the top left corner of the rectangle), width and height. (assume that the rectangle sides are parallel to the x and y axes. See example below). A constructor that creates a rectangle with the specified xpos, ypos, width, and height. Get and set methods for all the instance variables. A method contains(Rectangle r) that returns true if the specified rectangle is inside this rectangle. A method touches(Rectangle r) that returns true if the specified rectangle touches this rectangle. You may add other methods if necessary. Study the figures to understand when the contains method should return true, and when the touches method should return true. If the rectangles overlap, both methods should return false

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the best practices for managing a large software project?

Answered: 1 week ago

Question

How does clustering in unsupervised learning help in data analysis?

Answered: 1 week ago