Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.geometry.Point2D;
- public class Point2D_2 {
- // Main Method
- public static void main(String args[])
- {
- // Create three point2D objects
- Point2D point2d_1 = new Point2D(120.0f, 50.0f);
- Point2D point2d_2 = new Point2D(120.0f, 50.0f);
- Point2D point2d_3 = new Point2D(200.0f, 120.0f);
- // Display the coordinates of the 3 points
- display(point2d_1);
- display(point2d_2);
- display(point2d_3);
- // Check whether any point is equal to other or not
- System.out.println("Point 1 equals Point 2 = "
- + point2d_1.equals(point2d_2));
- System.out.println("Point 2 equals Point 3 = "
- + point2d_2.equals(point2d_3));
- System.out.println("Point 3 equals Point 1 = "
- + point2d_3.equals(point2d_1));
- // distance between two points
- System.out.println("Distane between point 1 and point 2 = "
- + point2d_1.distance(point2d_2));
- System.out.println("Distane between point 2 and point 3 = "
- + point2d_2.distance(point2d_3));
- System.out.println("Distane between point 3 and point 1 = "
- + point2d_3.distance(point2d_1));
- }
- // display method
- public static void display(Point2D point2d)
- {
- double x, y;
- // get the coordinates of the point
- x = point2d.getX();
- y = point2d.getY();
- // display the coordinates of the point
- System.out.println("x coordinate = " + x
- + ", y coordinate = " + y);
- // print its distance from origin
- System.out.println("Distance from origin = "
- + point2d.distance(0, 0));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement