mmayoub

RunCircle, 26.06.2021

Jun 26th, 2021
989
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. public class RunCircle {
  3.  
  4.     public static void main(String[] args) {
  5.         Circle c1;
  6.         Circle c2;
  7.  
  8.         // new circle with radius 1.0
  9.         c1 = new Circle();
  10.  
  11.         // new Circle with radius 7.0
  12.         c2 = new Circle(7);
  13.         // print radius of each circle
  14.         System.out.println(c1.getRadius());
  15.         System.out.println(c2.getRadius());
  16.  
  17.         // print c1 area
  18.         System.out.println(c1.getArea());
  19.  
  20.         // print c2 area
  21.         System.out.println(c2.getArea());
  22.  
  23.         // set radius to 5 for both circles
  24.         // c1.setRadius(5);
  25.         c2.setRadius(5);
  26.         // print radius of each circle
  27.         System.out.println(c1.getRadius());
  28.         System.out.println(c2.getRadius());
  29.  
  30.         // c1 and c2 are different objects
  31.         if (c1 == c2) {
  32.             System.out.println("Equal");
  33.         } else {
  34.             System.out.println("Not Equal");
  35.         }
  36.  
  37.         Circle c3 = c1;
  38.  
  39.         // c1 and c3 points to the same object
  40.         if (c1 == c3) {
  41.             System.out.println("Equal");
  42.         } else {
  43.             System.out.println("Not Equal");
  44.         }
  45.  
  46.         // print circle data
  47.         System.out.println(c1);
  48.         System.out.println(c2);
  49.         System.out.println(c3);
  50.  
  51.     }
  52.  
  53. }
  54.  
RAW Paste Data