Source of TestShapes.java


  1: //TestShapes.java

  3: public class TestShapes
  4: {
  5:     public static void main(String[] args)
  6:     {
  7:         Circle circle1 = new Circle(new Point(1.0, 1.0), 1.0);
  8:         Circle circle2 = new Circle(new Point(1.0, 1.0), 2.0);

 10:         Rectangle rectangle = new Rectangle(new Point(0.0, 1.0), 1.0, 1.0);

 12:         // Print areas
 13:         System.out.println("Area of circle 1 is: " + circle1.computeArea());
 14:         System.out.println("Area of circle 2 is: " + circle2.computeArea());
 15:         System.out.println("Area of rectangle is: " + rectangle.computeArea());
 16:         System.out.println();

 18:         // Print positions
 19:         System.out.println
 20:         (
 21:             "Circle 1 is at: (" + circle1.getPosition().getX() +
 22:             ", " + circle1.getPosition().getY() + ")"
 23:         );

 25:         System.out.println
 26:         (
 27:             "Rectangle is at: (" + rectangle.getPosition().getX() +
 28:             ", " + rectangle.getPosition().getY() + ")"
 29:         );
 30:         System.out.println();

 32:         // Move shapes
 33:         circle1.setPosition(new Point(3.0, 1.0));
 34:         rectangle.movePositionRelative(new Point(1.0, 1.0));

 36:         // Print positions
 37:         System.out.println
 38:         (
 39:             "Circle 1 is at: (" + circle1.getPosition().getX() +
 40:             ", " + circle1.getPosition().getY() + ")"
 41:         );

 43:         System.out.println
 44:         (
 45:             "Rectangle is at: (" + rectangle.getPosition().getX() +
 46:             ", " + rectangle.getPosition().getY() + ")"
 47:         );
 48:         System.out.println();
 49:     }
 50: }