14 changed files with 124 additions and 0 deletions
@ -0,0 +1,4 @@ |
|||
package PACKAGE_NAME; |
|||
|
|||
public class VariableTest { |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
package PACKAGE_NAME; |
|||
|
|||
public class j { |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
package com.test; |
|||
|
|||
public class Test { |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
### IntelliJ IDEA ### |
|||
out/ |
|||
!**/src/main/**/out/ |
|||
!**/src/test/**/out/ |
|||
.kotlin |
|||
|
|||
### Eclipse ### |
|||
.apt_generated |
|||
.classpath |
|||
.factorypath |
|||
.project |
|||
.settings |
|||
.springBeans |
|||
.sts4-cache |
|||
bin/ |
|||
!**/src/main/**/bin/ |
|||
!**/src/test/**/bin/ |
|||
|
|||
### NetBeans ### |
|||
/nbproject/private/ |
|||
/nbbuild/ |
|||
/dist/ |
|||
/nbdist/ |
|||
/.nb-gradle/ |
|||
|
|||
### VS Code ### |
|||
.vscode/ |
|||
|
|||
### Mac OS ### |
|||
.DS_Store |
|||
@ -0,0 +1,10 @@ |
|||
# 默认忽略的文件 |
|||
/shelf/ |
|||
/workspace.xml |
|||
# 已忽略包含查询文件的默认文件夹 |
|||
/queries/ |
|||
# Datasource local storage ignored files |
|||
/dataSources/ |
|||
/dataSources.local.xml |
|||
# 基于编辑器的 HTTP 客户端请求 |
|||
/httpRequests/ |
|||
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK"> |
|||
<output url="file://$PROJECT_DIR$/out" /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="ProjectModuleManager"> |
|||
<modules> |
|||
<module fileurl="file://$PROJECT_DIR$/w6.iml" filepath="$PROJECT_DIR$/w6.iml" /> |
|||
</modules> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="VcsDirectoryMappings"> |
|||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,3 @@ |
|||
public abstract class Animal { |
|||
public abstract void makeSound(); |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
public class Cat extends Animal{ |
|||
@Override |
|||
public void makeSound(){ |
|||
System.out.println("小猫喵喵叫:喵喵喵"); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
public class Dog extends Animal implements Swimmable { |
|||
@Override |
|||
public void makeSound(){ |
|||
System.out.println("小狗汪汪叫;汪汪汪"); |
|||
|
|||
} |
|||
@Override |
|||
public void swim(){ |
|||
System.out.println("小狗会游泳"); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
public class Main { |
|||
public static void main(String[] args){ |
|||
Animal myDog = new Dog(); |
|||
Animal myCat =new Cat(); |
|||
System.out.println("=== 动物叫声测试 ==="); |
|||
myDog.makeSound(); |
|||
myCat.makeSound(); |
|||
System.out.println("\n=== 游泳能力测试 ==="); |
|||
if (myDog instanceof Swimmable) { |
|||
((Swimmable) myDog).swim(); |
|||
} |
|||
if (myCat instanceof Swimmable) { |
|||
((Swimmable) myCat).swim(); |
|||
}else { |
|||
System.out.println("小猫不会游泳"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
public interface Swimmable { |
|||
void swim(); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<module type="JAVA_MODULE" version="4"> |
|||
<component name="NewModuleRootManager" inherit-compiler-output="true"> |
|||
<exclude-output /> |
|||
<content url="file://$MODULE_DIR$"> |
|||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
|||
</content> |
|||
<orderEntry type="inheritedJdk" /> |
|||
<orderEntry type="sourceFolder" forTests="false" /> |
|||
</component> |
|||
</module> |
|||
Loading…
Reference in new issue