2018-2019 Fall Semester Lab Exercise A1Assignment4Design a class named Rectangle. The class contains:a. Five private data fields [10 points] x (double) : The x position of the center. In a valid rectangle, the range ofx is in (-10, 10) y (double) : The y position of the center. In a valid rectangle, the range ofy is in (-10, 10) width (double) : The width of the rectangle. In a valid rectangle, the rangeof width is in [0, 5] height(double) : The height of the rectangle. In a valid rectangle, the rangeof height is in [0, 5] color (java.awt.Color): The color of rectangle.b. Design three constructors: [10 points]1. A constructor with two parameters including x and y2. A constructor with four parameters including x, y, width and height.3. A constructor with seven parameters, the first four parameters are doubletype, which represent the x, y, width and height of current rectangle,and the last three parameters are integers, which represent the red, greenand blue value of current color respectively. If a rectangle has no width and height, in constructor method we need toset width=1 and height=1 as default value. If a rectangle has no color, in constructor method we need to set a defaultcolor whose red, green and blue value are all 100. For the third constructor, if the value of red green and blue are largerthan 255 or smaller than 0, we need to set it as its closest boundaryvalue.c. Design the getter and setter method for each private field of Rectangle. [10points]d. Design a toString() method, which can return a String value as followingoutput format. [10 points]The first test:public class Test1 {public static void main(String[] args) {Rectangle r1=new Rectangle(0,1,2,2,100,150,100);Rectangle r2=new Rectangle(3,1,3,1,-1,350,100);Rectangle r3=new Rectangle(2,2);Rectangle r4=new Rectangle(3,-1,2,2);System.out.println(r1);2018-2019 Fall Semester Lab Exercise A2System.out.println(r2);System.out.println(r3);System.out.println(r4);}}e. Design a public method named intersect() with a Rectangle parameter and areturn value (boolean). If the current rectangle is intersected with theparameter rectangle, it will return true, otherwise it will return false. [10points]f. Design a public static method named intersect() with two Rectangleparameters and a return value (boolean). If two rectangles are intersected, itwill return true, otherwise it will return false. [10 points]The Second Test:public class Test2 {public static void main(String[] args) {Rectangle r1=new Rectangle(0,0,2,2,100,50,100);Rectangle r2=new Rectangle(1.5,2,3,1,-1,350,100);Rectangle r3=new Rectangle(1.6,-1,1,3,50,100,200);Rectangle r4=new Rectangle(1,1,1,2,180,100,40);System.out.println(r1.intersect(r2));System.out.println(r1.intersect(r3));System.out.println(r1.intersect(r4));System.out.println(Rectangle.intersect(r3, r4));}}g. Design a public method named isValid() with a return value (boolean). Onlywhen the range of its width and height are in [0, 5] (0 and 5 are included) andCentre[0.0,1.0] Shape[2.0,2.0] Color[100,150,100]Centre[3.0,1.0] Shape[3.0,1.0] Color[0,255,100]Centre[2.0,2.0] Shape[1.0,1.0] Color[100,100,100]Centre[3.0,-1.0] Shape[2.0,2.0] Color[100,100,100]falsefalsetruetrue2018-2019 Fall Semester Lab Exercise A3the range of it x and y position are in (-10,10) (-10 and 10 are not included)代写Fall Semester作业、代做Java编程语言作业、代写Rectangle留学生作业、代做Java作业 帮做J, itwill return true, otherwise it will return false. [10 points]h. Design a public method named isInBoundary() with a return value (boolean).If the whole rectangle can be drawn in the screen (-10,10), it will return true,otherwise it will return false. [10 points]The third Test:Rectangle r1=new Rectangle(-2,1,5,5,100,150,200);Rectangle r2=new Rectangle(9,1,5,5,250,100,40);System.out.println(r1.isInBoundary());System.out.println(r2.isInBoundary()); ‘(The whole rectangle of the blue one can be drawn in the screen, so it is in boundary,but the orange one is not.)i. In same package, we create a class named RectangleTest, in which there is amain method. In main method, we will read several lines as following format.For each line, we need create an object of Rectangle according to the data inline. After that, we need to output all valid rectangles, which are not intersectwith the first valid rectangle in the line order. [10 points]The fourth Test:Sample input:2018-2019 Fall Semester Lab Exercise A49.27,6.61,3,7.18,209,144,2473.4,4.0,4.5,4.5,100,100,100-2.89,7.61,5.57,5.068.43,6.667.42,0.68,2.07,2.93,78,39,1656.70,1.54,3.52,3.121.14,0.76,2.37,3.07,236,105,1371.06,-0.80,3.03,2.66,132,120,2733.01,-9.08,2.76,2.36,138,148,119-0.51,-4.99,6.42,5.65-4.36,8.70,3.03,2.63,16,138,2219.40,2.41,6.47,4.90Sample output:j. Design a public method named draw() , in which we need to draw the currentrectangle in screen. We need to make sure that: [10 points] Only draw the valid rectangle. The rectangle in screen needs to have its color.In main method, adding following two statements, just before you using drawmethod.StdDraw.setXscale(-10,10);StdDraw.setYscale(-10,10);The fifth Test:Sample input:-4.98,-8.00,3.29,1.660.17,-8.00,2.37,3.434.04,-8.00,1.67,1.776.84,-8.00,3.35,3.30,87,9,2606.84,-4.03,2.20,2.83,200,139,786.84,-0.89,3.04,1.97,122,195,146.84,2.636.84,6.09,2.04,1.804.36,6.09Centre[8.4,6.7] Shape[1.0,1.0] Color[100,100,100]Centre[7.4,0.7] Shape[2.1,2.9] Color[78,39,165]Centre[1.1,-0.8] Shape[3.0,2.7] Color[132,120,255]Centre[3.0,-9.1] Shape[2.8,2.4] Color[138,148,119]Centre[-4.4,8.7] Shape[3.0,2.6] Color[16,138,221]2018-2019 Fall Semester Lab Exercise A50.64,6.09,3.07,3.25,-10,299,288-2.28,6.09,2.56,3.22-5.19,6.09,1.68,2.37,-20,-30,184-5.19,3.68,3.11,2.34-5.19,-0.82-5.19,-4.86,2.67,2.99,129,7,49Sample output:Sample input:-1.96,-8.00,2.99,-2.39,230,119,1482.80,-8.007.23,-8.00,2.44,3.207.23,-4.07,2.63,2.04,241,27,2677.23,0.57,8.84,1.987.23,5.917.23,9.18,-2.15,2.263.26,9.181.15,9.18,1.86,2.16,69,204,101-2.51,9.18,2.52,3.41-5.18,9.18,-1.02,3.172018-2019 Fall Semester Lab Exercise A6-6.18,6.75,-2.51,2.22,81,26,176-7.18,2.01,2.43,2.88,116,85,169-8.18,-1.42Sample output:What to submit1. Please submit three “.java” files including “Rectangle.java”“RectangleTest.java” and “StdDraw.java”, and make sure thatthose “.java” files have no package information included. Rectangle.java: It is for you to create and edit all questions. RectangleTest.java: It is for you to add necessary code to finish question i, and do not remove other code in this file. StdDraw.java: You can do no change about this file, but do not forget to remove package information if you added it.2. Please submit those three files into sakai website before deadline转自:http://ass.3daixie.com/2018112013362282.html