Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Questiorn (0.0,0.0) xpos, ypos (10.0, 5.0 height-2.0 width 3.0 Define a Rectangle2D class that has the following private attributes: . double xPos double yPos .

image text in transcribedimage text in transcribed

Questiorn (0.0,0.0) xpos, ypos (10.0, 5.0 height-2.0 width 3.0 Define a Rectangle2D class that has the following private attributes: . double xPos double yPos . double width double height and the following methods A no-arg constructor (e.g., header: public Rectangle ( )that creates a default rectangle with (0.0, 0.0) for (xpos, ypos) and 0.0 for both width and height. 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 getArea() that returns the area of the rectangle A method isEqual(Rectangle2D r) that returns the true if this rectangle and rectangle r have the same attributes A method isSmaller (Rectangle2D r) that returns true if the area of this rectangle is smaller than the area of r . A method contains(double x, double y) that returns true if the specified point (x. y) is inside this rectangle. See below figure A toString method that prints out the x and y position, and the length and width of the rectangle point p has a x and y poaition that is inside the rectangle Then create a Rectangle2DDemo class to create and use Rectangle2D objects. The Rectangle2DDemo class contains the main method. Use a Scanner object to read the attributes for two Rectangle2D objects Create Rectangle2D objects by passing in the attributes read in by the Scanner object

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

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions