# 추상 클래스 추출하기 - 2 ## 문제 뼈대코드의 클래스에서 추상클래스를 추출하여 모든 도형의 넓이가 출력되도록 코드를 수정하시오. (메인 메소드 변경 금지) ## 출력 예 ``` 28.27 31.18 90.00 ``` ## 뼈대코드 ``` public class Main { public static void main(String[] args) { Circle c = new Circle(1, 2, 3); EquilateralTriangle t = new EquilateralTriangle(4, 5, 6); Rectangle r = new Rectangle(7, 8, 9, 10); // 그룹화 Shape[] shapes = { c, t, r }; // 모든 도형의 넓이를 출력 for (Shape s : shapes) { System.out.println(s.getArea()); } } } class Circle { int centerX; int centerY; int radius; } class EquilateralTriangle { int centerX; int centerY; int length; } class Rectangle { int centerX; int centerY; int width; int height; } ```
관련 강의로 이동

코드: java 1.8

public class Main { public static void main(String[] args) { } }

입력

정답이 궁금하다면? 코드를 제출해보세요!