In this assignment, we'll assess the following skills,
Starting point is provided in comp1010_s1_2020_assignment_2_template.zip.
It IS full of compilation errors because Point class isn't implemented. That's your first task. So, read on :)
The Point class represents a point in a 2-dimensional plane. For the sake of simplicity, we limit points to the first quadrant where the x and y coordinates are non-negative.
You should start by studying the test file PointTest.java and making notes. See which are the variables being accessed and what is the type of values they are being compared against. For example, if there is something like:
Student s = new Student("Ginny", 87);
assertEquals(87, s.mark);
It indicates that the class Student has an instance variable mark of type int (otherwise the assertion would be assertEquals(87, s.mark, 0.001); where 0.001 is the tolerance.
The JUnit tests have comments where required. Study those comments. One thing I will recommend is to do the following in given order.
You can implement getPathToOrigin recursively. And I suggest you give that a shot.
For our purpose, a polygon is a collection of points and straight lines connect each adjacent point in the array (where the last and first item are considered adjacent points as well).
So, a polygon from (1,1) to (4,1) to (2, 3) to (5, 2) (and back to 1, 1) is a Polygon , and has two edges intersecting, which is fine. For more details, see the following and feel free to do your own research.
https://en.wikipedia.org/wiki/Polygon https://www.mathsisfun.com/definitions/polygon.html
Note that the tests for Polygon are not provided. You can use the following input output mappings.
This class contains only one method - getPointsOnCrosshair, which is our question.
Creating helper methods