Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Point p2 = new Point(0.9, 0.1); Point p3 = new Point(0.5, 0.9); Draw page= new Draw(Nested Traingle); ArrayList points = new ArrayList (); points =
Point p2 = new Point(0.9, 0.1); Point p3 = new Point(0.5, 0.9);
Draw page= new Draw("Nested Traingle"); ArrayList
SAMPLE CODE
public static ArrayList drillPoints(Point p1, Point p2, Point p3, int order, Draw page, ArrayList array) { // your code goes here. Task 3 return new ArrayList(); }
For this task, we are going to have nested triangles. The robot wants to drill a hole on the vertices of triangles and draw a line for the horizontal side of the triangles. This method starts with three points, which are the vertices of the largest (the most outer) triangle. A nested triangle is a triangle, whose vertices fall on the midpoints of the sides of the outer triangle. The method gets an integer called order, that specifies how deeply the recursive method should be called. If order = 1, only one horizontal line and three points are drawn, and three points are returned as the coordinates that should be drilled by the robot. Please see the pictures below where nested triangles with different orders are created by the robot. To make it more visible, the points that should be drilled and returned from the method are drawn in black. You don't need to change the color as we only check the return value of the method. Since this method is recursive, it is possible that a drilled point (i.e. a triangle vertex) is computed more than once. The ArrayList that holds the points should not contain any duplicate points. Also, for the ease of testing, we ask you to add point.toString() to the ArrayList. This method can be found in Point class. order = 1 (one line and 3 points are drawn). order=2 (two lines and 6 points are drawn) order=3 (5 lines and 15 points are drawn) order = 5 Sample Call 1: Point pl - new Point(0.1, 0.1); For this task, we are going to have nested triangles. The robot wants to drill a hole on the vertices of triangles and draw a line for the horizontal side of the triangles. This method starts with three points, which are the vertices of the largest (the most outer) triangle. A nested triangle is a triangle, whose vertices fall on the midpoints of the sides of the outer triangle. The method gets an integer called order, that specifies how deeply the recursive method should be called. If order = 1, only one horizontal line and three points are drawn, and three points are returned as the coordinates that should be drilled by the robot. Please see the pictures below where nested triangles with different orders are created by the robot. To make it more visible, the points that should be drilled and returned from the method are drawn in black. You don't need to change the color as we only check the return value of the method. Since this method is recursive, it is possible that a drilled point (i.e. a triangle vertex) is computed more than once. The ArrayList that holds the points should not contain any duplicate points. Also, for the ease of testing, we ask you to add point.toString() to the ArrayList. This method can be found in Point class. order = 1 (one line and 3 points are drawn). order=2 (two lines and 6 points are drawn) order=3 (5 lines and 15 points are drawn) order = 5 Sample Call 1: Point pl - new Point(0.1, 0.1)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