From 3582a7ba6bca5b4952d883b4298287bb7ddcbb5e Mon Sep 17 00:00:00 2001 From: zhangsiyuan <3837703520@qq.com> Date: Fri, 3 Apr 2026 15:56:49 +0800 Subject: [PATCH] =?UTF-8?q?w5-=E5=BC=A0=E6=80=9D=E6=B8=8A-202401070104?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- w5/Main.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 w5/Main.java diff --git a/w5/Main.java b/w5/Main.java new file mode 100644 index 0000000..4425e53 --- /dev/null +++ b/w5/Main.java @@ -0,0 +1,24 @@ +abstract class Shape{ + public abstract void draw(); +} +class Rectangle extends Shape{ + public void draw(){ + System.out.println("画一个矩形"); + } +} +class Circle extends Shape{ + public void draw(){ + System.out.println("画一个圆"); + } +} +public class Main{ + public static void drawShape(Shape s){ + s.draw(); + } + public static void main(String[] args){ + Shape shape = new Rectangle(); + drawShape(shape); + Shape shape2 = new Circle(); + drawShape(shape2); + } +} \ No newline at end of file