From 9a886b36a7e0f81ccd2f7424c609ffd7f7059f68 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Wed, 23 Oct 2024 12:59:55 +0900 Subject: [PATCH] =?UTF-8?q?[CHORE]=20chapter=206-2=20=EC=A0=95=EB=8B=B5=20?= =?UTF-8?q?=EA=B8=B0=EC=9E=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chapter6/euna/chapter6-2.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chapter6/euna/chapter6-2.java b/chapter6/euna/chapter6-2.java index ccfe65e..fbf24f5 100644 --- a/chapter6/euna/chapter6-2.java +++ b/chapter6/euna/chapter6-2.java @@ -19,12 +19,18 @@ public class Geometry { public double area(Object shape) throws NoSuchShapeException { if (shape instanceof Square) { /* 구현하세요 */ + Square square = (Square)shape; + return square.side * square.topLeft; } else if (shape instanceof Rectangle) { /* 구현하세요 */ + Rectangle rectagle = (Rectangle)shape; + return rectagle.height * rectagle.width; } else if (shape instanceof Circle) { /* 구현하세요 */ + Circle cirle = (Circle)circle; + return circle.radius*circle.radius*PI; } throw new NoSuchShapeException(); }