Advertisement
mmayoub

MainClass, 12.06.2021

Jun 12th, 2021
1,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package prj12062021;
  2.  
  3. public class MainClass {
  4.  
  5.     public static void main(String[] args) {
  6.         Point p1 = new Point();
  7.         p1.print();
  8.         System.out.println(p1);
  9.         Point p2 = new Point();
  10.         p2.setX(3);
  11.         p2.setY(4);
  12.         p2.print();
  13.  
  14.         Point p3 = new Point(3, 4);
  15.         p3.print();
  16.  
  17.         Point p4 = p1;
  18.         p4.print();
  19.  
  20.         System.out.println(" p1 ***************");
  21.         System.out.println("p1==p2 : " + (p1 == p2));
  22.         System.out.println("p1==p3 : " + (p1 == p3));
  23.         System.out.println("p1==p4 : " + (p1 == p4));
  24.  
  25.         System.out.println(" p2 ***************");
  26.         System.out.println("p2==p3 : " + (p2 == p3));
  27.         System.out.println("p2==p4 : " + (p2 == p4));
  28.         System.out.println("p2.equals(p3) : " + p2.equals(p3));
  29.  
  30.         System.out.println("from p1 to p2 : " + p1.distance(p2));
  31.         System.out.println("from p2 to p1 : " + p2.distance(p1));
  32.         System.out.println("from p2 to p3 : " + p2.distance(p3));
  33.     }
  34.  
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement