Example #1
0
  public static void main(String[] args) {

    /**/
    // UNCOMMENT THIS WHEN YOU DO AREA
    Area[] twos = new Area[5];
    for (int i = 0; i < twos.length; i++) {
      twos[i] = makeRandomAreaShape();
    }
    System.out.println("Area tests:");
    for (Area a : twos) {
      System.out.println(a);
      System.out.println(a.getArea());
    }

    /**/
    // UNCOMMENT THIS WHEN YOU DO VOLUME
    Volume[] threes = new Volume[6];
    for (int i = 0; i < threes.length; i++) {
      threes[i] = makeRandomVolumeShape();
    }
    System.out.println("\nVolume tests:");
    for (Volume v : threes) {
      System.out.println(v);
      System.out.println(v.getVolume());
    }
  }
  /** @param args the command line arguments */
  public static void main(String[] args) {
    Rectangle rect = new Rectangle();
    System.out.println(rect.getWidth());

    Rectangle square = new Rectangle(4, 4);
    System.out.println(square.getWidth());
    System.out.println(square.getLength());

    Area a1 = new Area(square);
    a1.calcArea();
    System.out.println(a1.getArea());
    square.scale(-2);
    System.out.println(square.getWidth());
    System.out.println(square.getLength());
    a1.calcArea();
    System.out.println(a1.getArea());

    Rectangle anotherRect = new Rectangle(8, 10);
    square = anotherRect;
    a1.calcArea();
    System.out.println(a1.getArea());
  }