Java Project. make a new Java class called rectangleCovering . make…Java Project.make a new Java class calledrectangleCovering.make a static method that accepts two rectangles andreturnstheso-calledcovering rectangle.Use the declarationpublic static RectanglefindCovering(Rectangle R1, Rectangle R2)The covering rectangle is formed by connecting the center of one rectangle to the center of the other rectangle with a line. This line forms the diagonal of the covering rectangle. In the below picture the lightly edged rectangle is the covering rectangle.However, if the centers of the two rectangles are in line in the x-direction or the y-direction (i.e, the centers have the same x-coordinate or the same y-coordinate) then the covering rectangle won’t be well defined (either the width or the height won’t be well defined). In this case, use the minimum width or height of the two rectangles for the covering rectangle.In the above picture, the x-locations of the centers of the left most rectangles are the same. Unlike the previous case, you won’t be able to find the width of the covering rectangle (it isn’twell defined). In this case, use the width of the smaller rectangle. The right most set of rectangles show the other case.If the y-locations of the centers match up, use the minimum height of the rectangles. Lastly, if the centers are the same the covering rectangle is defined to be the intersection of the two rectangles. To save you coding, in this case call thebuilt inintersection method for rectangles.In the main method, you will test your routine. Create four sets of two rectangles. Each set of rectangles should test one of the four cases above.For each set, call yourfindCoveringmethod. For each set, print a readable version of each rectangle and the covering rectangle. So, you should have a total of 12 printed things (3 per set, 4 sets).Make sure that your code is adequately commented.What I have done.import java.awt.Rectangle;public class rectangleWork { public static double perimeter(Rectangle r) { return 2*r.getWidth()*r.getHeight(); } public static double area(Rectangle r) { return r.getWidth()*r.getHeight(); } public static double[] getCenter(Rectangle r) { double[] center= new double[2]; center[0]=r.getX().getWidth()/2; center[1]=r.getY().getHeight()/2; return center; } //Compute the center-to-center distance between two rectangles. public static double distance(Rectangle r1, Rectangle r2) { double[] c1 = getCenter(r1); double[] c2 = getCenter(r2); return Math.sqrt((c1[0]-c2[0])*(c1[0]-c2[0])(c1[1]-c2[1])*(c1[1]-c2[1])); } public static void main(String[] args) { Rectangle r1 = new Rectangle(40,20,100,400); Rectangle r2 = new Rectangle(40,20,500,100); System.out.println(distance(r1,r2)); }}Computer Science Engineering & Technology Java Programming CIS 121
solved : Java Project. make a new Java class called rectangleCovering
How it works
- Paste your instructions in the instructions box. You can also attach an instructions file
- Select the writer category, deadline, education level and review the instructions
- Make a payment for the order to be assigned to a writer
- Download the paper after the writer uploads it
Will the writer plagiarize my essay?
You will get a plagiarism-free paper and you can get an originality report upon request.
Is this service safe?
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
LET THE PROFESSIONALS WRITE YOUR PAPER!