Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Square , will implement a data type Square that represents squares with the x and y coordinates of their upper - left corners and the

Square, will implement a data type Square that represents squares with the x and y coordinates of their upper-left corners and the length.
The API should be as follows.
Square(double x, double y, double length)//constructor
double area()//returns the area of the square
double perimeter()//returns the perimeter of the square
boolean intersects(Square b)//does this square intersect b? Two squares would intersect if they share one or more common points
boolean contains(Square b)//does this square contain b?
void draw()//draw this square on standard drawing
Note: The program should include a main method to test that it does the following.
Instantiate a Square object whose upper-left corner coordinates and length are given as command-line arguments. It should print out the area and perimeter of the square.
Prompt the user for a second squares upper-left corner coordinates and length, and indicate whether it intersects with the square specified earlier and also whether it contains the square specified earlier.
Provide a pop-up window that displays the two squares.
A sample run would be as follows.
>java Square 0.20.70.3
The area is 0.09
The perimeter is 1.2
Enter the upper-left coordinates and the length of a square: 0.30.60.4
It intersects the first square.
It does not contain the first square.
Also a window should pop up that displays both the squares. in java

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

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions

Question

When are period costs expensed? When are product costs expensed?

Answered: 1 week ago

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago