From 443615ca4d5d35c91bee11a5a9d64200e376aedd Mon Sep 17 00:00:00 2001 From: YuWeixia Date: Mon, 13 Apr 2026 16:42:54 +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'w6'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- w6/Animalsound.java.java | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 w6/Animalsound.java.java diff --git a/w6/Animalsound.java.java b/w6/Animalsound.java.java new file mode 100644 index 0000000..be09a57 --- /dev/null +++ b/w6/Animalsound.java.java @@ -0,0 +1,39 @@ +package w6; + +abstract class Animal { + public abstract void makeSound(); +} +interface Swimmable{ + void swim(); +} +class Dog extends Animal implements Swimmable{ + @Override + public void makeSound() { + System.out.println("汪汪汪"); + } + @Override + public void swim() { + System.out.println("狗会游泳"); + } +} +class Cat extends Animal { + @Override + public void makeSound() { + System.out.println("喵喵喵"); + } +public class Test{ + public static void main(String[] args) { + Animal dog = new Dog(); + dog.makeSound(); + ((Swimmable) dog).swim(); + Animal cat = new Cat(); + cat.makeSound(); + + } +} + + + + +} +