1 2 public class Figure { 3 public double getArea(int length, String shape){ 4 double area = 0; 5 if (shape.equals("Square")){ 6 // length * length 7 Square square = new Square(length); 8 area = square.getArea(); 9 } else if (shape.equals("Circle")){ 10 // pi * length * length 11 Circle circle = new Circle(length); 12 area = circle.getArea(); 13 } else if (shape.equals("EquilateralTriangle")){ 14 // (Square root 3 / 4) * length * length 15 EquilateralTriangle equilateralTriangle = new EquilateralTriangle(length); 16 area = equilateralTriangle.getArea(); 17 } 18 return area; 19 } 20 }