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 area = Math.pow(length,2); 8 } else if (shape.equals("Circle")){ 9 // pi * length * length 10 area = Math.PI * Math.pow(length,2); 11 } else if (shape.equals("EquilateralTriangle")){ 12 // (Square root 3 / 4) * length * length 13 area = (Math.sqrt(3.0) / 4) * Math.pow(length,2); 14 } 15 return area; 16 } 17 }