Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A polyline is a line with segments formed by a list of points of type MyPoint. Let's use the ArrayList (dynamically allocated array) to keep
A polyline is a line with segments formed by a list of points of type MyPoint. Let's use the ArrayList (dynamically allocated array) to keep the points It contains A private instance variable: an ArrayList of MyPoint objects A default (or "no-argument" or "no-arg" constructor that constructs an empty ArrayList. An overloaded constructor that constructs a PolyLine object with the given list of MyPoint. An overridden tostring() method that returns a string description of the polyline in this format: ((x1,y1) (x2,y2) (x3,y3).. A method named appendMyPoint (MyPoint) which appends a MyPoint object to the end of the current polyline. . An overloaded method appendMyPoint(x, y) which appends a MyPoint(x, y) to the end of the current polyline A method named removeLastMyPoint() that removes the last MyPoint from the current polyine. .A method named getMyPoint (index) that returns the MyPoint object at the specified position in this polyline Write the PolyLine class in the answer box below assuming that the MyPoint class has been done for you in the system. Note - keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks. For example: Result PolyLine line - new PolyLine) line.appendMyPoint (new MyPoint(1, 2)) line.appendMyPoint(3, 4); line.appendMyPoint(5, 6); System.out.println(line)
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