Advertisement
mmayoub

RunPoint, 03.07.2021

Jul 10th, 2021
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1.  
  2. public class RunPoint {
  3.  
  4.     public static void main(String[] args) {
  5.  
  6.         System.out.println("The program created " + Point.getCount() + " points");
  7.  
  8.         Point p1 = new Point(43, 7);
  9.         Point p2 = new Point(5, 5);
  10.  
  11.         System.out.println(p1);
  12.         System.out.println(p2);
  13.  
  14.         System.out.println("----------------------");
  15.         double tempX;
  16.  
  17.         tempX = p1.getX(); // 1
  18.         p1.setX(p2.getX()); // 2
  19.         p2.setX(tempX); // 3
  20.  
  21.         System.out.println(p1);
  22.         System.out.println(p2);
  23.  
  24.         // distance from p1 to p2
  25.         System.out.println(p1.distance(p2));
  26.  
  27.         if (p1.distance(p2) > 10) {
  28.             System.out.println("too far");
  29.  
  30.         }
  31.  
  32.         // mid point
  33.         System.out.println("Mid Point is " + p1.middle(p2));
  34.  
  35.         Point p3 = p1;
  36.         System.out.println("p1:" + p1);
  37.         System.out.println("p3:" + p3);
  38.  
  39.         Point p4 = new Point(p1.getX(), p2.getY() + p1.getY());
  40.         System.out.println("p4: " + p4);
  41.  
  42.         p1.setX(100);
  43.         System.out.println("p1:" + p1);
  44.         System.out.println("p3:" + p3);
  45.  
  46.         System.out.println(p3.distance(p4));
  47.         System.out.println(p3.middle(p4));
  48.  
  49.         System.out.println("The program created " + Point.getCount() + " points");
  50.  
  51.     }
  52.  
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement