For the following, assume that the import of java.awt.* is at the top of the program, so that the JDK Point class is available.
Note new simplified version of problem 3: using JDK Points
3. Consider PointMain.java on pp. 530-531. You can download it from the authors’ website (directory Point_5_fancy) using a link on the class web page. Modify PointMain to use JDK Points by adding “import java.awt.*” at the top of the program. Delete the lines that call method “distanceFromOrigin”. Modfiy PointMain to print out the two points like this, using their values, so that other points would also work.
1. Write a line of code to create a Point at (5,4) and call it myPoint.
2. Write a line of code that sets an int x variable to the x coordinate of myPoint.
double x = myPoint.getX(); // using getX(), get x coordinate of Point, provided in class
3. Write a line of code to change myPoint by translating it by (1,0)
4. What is the new position of myPoint in (x,y) notation?
5. Write a line of code to make a new reference variable called pt2 that also references the Point object called myPoint above. Draw a picture of the two references and the object.
6. Write a line of code that translates pt2 by (1,1)
7. Where is the point pt2 now in (x,y) notation?
8. Where is the point myPoint now in (x,y) notation?
9. Write a loop that prints out 5 hyphens by printing them one at a time.
10. Generalize your code to print out x hyphens, where x is in an int variable. Just fix the code above.
11. Now put 2. And 10. Together to write a loop that shows the x coordinate of a Point p.
For example, if p is at (5,4), it should print 4 hyphens, whereas if p is at (8,1), it should print 8 hyphens.
12. If you have time, put your code from 11. Into a method called showXCoord, that takes a Point argument and returns void.