Answered step by step
Verified Expert Solution
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 upperleft corners and the length.
The API should be as follows.
Squaredouble x double y double lengthconstructor
double areareturns the area of the square
double perimeterreturns the perimeter of the square
boolean intersectsSquare bdoes this square intersect b Two squares would intersect if they share one or more common points
boolean containsSquare bdoes this square contain b
void drawdraw 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 upperleft corner coordinates and length are given as commandline arguments. It should print out the area and perimeter of the square.
Prompt the user for a second squares upperleft 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 popup window that displays the two squares.
A sample run would be as follows.
java Square
The area is
The perimeter is
Enter the upperleft coordinates and the length of a square:
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started