- If you haven’t completed Point Objects, do so now.
- Open PointObject.java and add the following method.
public static void pointPoint(Point p){
System.out.println("(" + p.x + ", " + p.y + ")");
}
- Add a call to main. The complete class should appear as follows. Note the class contains code from the Attributes exercise as well as this exercise.
import java.awt.Point;
public class PointObject {
public static void pointPoint(Point p){
System.out.println("(" + p.x + ", " + p.y + ")");
}
public static void main(String[] args){
Point blank;
blank = new Point(3,4);
System.out.println(blank.toString());
System.out.println(blank.x + "," + blank.y);
int sum = blank.x * blank.x + blank.y * blank.y;
System.out.println(sum);
PointObject.pointPoint(blank);
}
}
- Compile and run the program.
$ javac PointObject.java
$ java PointObject
java.awt.Point[x=3,y=4]
3,4
25
(3, 4)