From 78f353a99dbf80ef484711c4e193704ce34e4818 Mon Sep 17 00:00:00 2001 From: LiuZihan <1353843969@qq.com> Date: Fri, 3 Apr 2026 23:55:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'w5=20Shape'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- w5 Shape/Circle.java | 6 ++++++ w5 Shape/Rectangle.java | 6 ++++++ w5 Shape/Shape.java | 5 +++++ w5 Shape/TestShape.java | 15 +++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 w5 Shape/Circle.java create mode 100644 w5 Shape/Rectangle.java create mode 100644 w5 Shape/Shape.java create mode 100644 w5 Shape/TestShape.java diff --git a/w5 Shape/Circle.java b/w5 Shape/Circle.java new file mode 100644 index 0000000..91de31b --- /dev/null +++ b/w5 Shape/Circle.java @@ -0,0 +1,6 @@ +public class Circle extends Shape { + @Override + public void draw() { + System.out.println("绘制一个圆形"); + } +} \ No newline at end of file diff --git a/w5 Shape/Rectangle.java b/w5 Shape/Rectangle.java new file mode 100644 index 0000000..70bfee8 --- /dev/null +++ b/w5 Shape/Rectangle.java @@ -0,0 +1,6 @@ +public class Rectangle extends Shape { + @Override + public void draw() { + System.out.println("绘制一个矩形"); + } +} \ No newline at end of file diff --git a/w5 Shape/Shape.java b/w5 Shape/Shape.java new file mode 100644 index 0000000..ee4fea3 --- /dev/null +++ b/w5 Shape/Shape.java @@ -0,0 +1,5 @@ +public class Shape { + public void draw() { + System.out.println("绘制一个形状"); + } +} \ No newline at end of file diff --git a/w5 Shape/TestShape.java b/w5 Shape/TestShape.java new file mode 100644 index 0000000..416244e --- /dev/null +++ b/w5 Shape/TestShape.java @@ -0,0 +1,15 @@ +public class TestShape { + + public static void drawShape(Shape s) { + s.draw(); + } + + public static void main(String[] args) { + Shape shape = new Shape(); + Circle circle = new Circle(); + Rectangle rectangle = new Rectangle(); + drawShape(shape); + drawShape(circle); + drawShape(rectangle); + } +} \ No newline at end of file