From a3eb86f50df5167fb7d1d74ad45f30675766c1c7 Mon Sep 17 00:00:00 2001 From: WangYangyang <3093159564@qq.com> Date: Sun, 12 Apr 2026 10:43:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=8B=E7=83=8A=E7=83=8A202302050115W6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pom.xml | 2 +- .../src/main/java/org/example/App.java | 0 .../src/test/java/org/example/AppTest.java | 0 MyPic/pom.xml | 25 ++++++++++++ MyPic/src/main/java/org/example/App.java | 13 ++++++ MyPic/src/test/java/org/example/AppTest.java | 38 ++++++++++++++++++ interface/pom.xml | 25 ++++++++++++ interface/src/main/java/org/example/App.java | 13 ++++++ .../src/test/java/org/example/AppTest.java | 38 ++++++++++++++++++ w6/pom.xml | 25 ++++++++++++ w6/src/main/java/com/w6/Animal.java | 5 +++ w6/src/main/java/com/w6/Cat.java | 8 ++++ w6/src/main/java/com/w6/Dog.java | 11 +++++ w6/src/main/java/com/w6/Main.java | 18 +++++++++ w6/src/main/java/com/w6/Swimmable.java | 5 +++ w6/src/main/java/org/example/App.java | 13 ++++++ w6/src/test/java/org/example/AppTest.java | 38 ++++++++++++++++++ w6/target/classes/com/w5/Animal.class | Bin 0 -> 277 bytes w6/target/classes/com/w5/Cat.class | Bin 0 -> 469 bytes w6/target/classes/com/w5/Dog.class | Bin 0 -> 590 bytes w6/target/classes/com/w5/Main.class | Bin 0 -> 901 bytes w6/target/classes/com/w5/Swimmable.class | Bin 0 -> 127 bytes w6/target/classes/org/example/App.class | Bin 0 -> 537 bytes 实验一CarProject/pom.xml | 25 ++++++++++++ .../src/main/java/org/example/App.java | 13 ++++++ .../src/test/java/org/example/AppTest.java | 38 ++++++++++++++++++ 26 files changed, 352 insertions(+), 1 deletion(-) rename {封装继承多态 => Encapsulation_Inheritance_Polymorphism}/pom.xml (91%) rename {封装继承多态 => Encapsulation_Inheritance_Polymorphism}/src/main/java/org/example/App.java (100%) rename {封装继承多态 => Encapsulation_Inheritance_Polymorphism}/src/test/java/org/example/AppTest.java (100%) create mode 100644 MyPic/pom.xml create mode 100644 MyPic/src/main/java/org/example/App.java create mode 100644 MyPic/src/test/java/org/example/AppTest.java create mode 100644 interface/pom.xml create mode 100644 interface/src/main/java/org/example/App.java create mode 100644 interface/src/test/java/org/example/AppTest.java create mode 100644 w6/pom.xml create mode 100644 w6/src/main/java/com/w6/Animal.java create mode 100644 w6/src/main/java/com/w6/Cat.java create mode 100644 w6/src/main/java/com/w6/Dog.java create mode 100644 w6/src/main/java/com/w6/Main.java create mode 100644 w6/src/main/java/com/w6/Swimmable.java create mode 100644 w6/src/main/java/org/example/App.java create mode 100644 w6/src/test/java/org/example/AppTest.java create mode 100644 w6/target/classes/com/w5/Animal.class create mode 100644 w6/target/classes/com/w5/Cat.class create mode 100644 w6/target/classes/com/w5/Dog.class create mode 100644 w6/target/classes/com/w5/Main.class create mode 100644 w6/target/classes/com/w5/Swimmable.class create mode 100644 w6/target/classes/org/example/App.class create mode 100644 实验一CarProject/pom.xml create mode 100644 实验一CarProject/src/main/java/org/example/App.java create mode 100644 实验一CarProject/src/test/java/org/example/AppTest.java diff --git a/封装继承多态/pom.xml b/Encapsulation_Inheritance_Polymorphism/pom.xml similarity index 91% rename from 封装继承多态/pom.xml rename to Encapsulation_Inheritance_Polymorphism/pom.xml index 78426ca..43f962d 100644 --- a/封装继承多态/pom.xml +++ b/Encapsulation_Inheritance_Polymorphism/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.example - 封装继承多态 + Encapsulation_Inheritance_Polymorphism 1.0-SNAPSHOT jar diff --git a/封装继承多态/src/main/java/org/example/App.java b/Encapsulation_Inheritance_Polymorphism/src/main/java/org/example/App.java similarity index 100% rename from 封装继承多态/src/main/java/org/example/App.java rename to Encapsulation_Inheritance_Polymorphism/src/main/java/org/example/App.java diff --git a/封装继承多态/src/test/java/org/example/AppTest.java b/Encapsulation_Inheritance_Polymorphism/src/test/java/org/example/AppTest.java similarity index 100% rename from 封装继承多态/src/test/java/org/example/AppTest.java rename to Encapsulation_Inheritance_Polymorphism/src/test/java/org/example/AppTest.java diff --git a/MyPic/pom.xml b/MyPic/pom.xml new file mode 100644 index 0000000..354d734 --- /dev/null +++ b/MyPic/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + org.example + MyPic + 1.0-SNAPSHOT + jar + + project2 + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/MyPic/src/main/java/org/example/App.java b/MyPic/src/main/java/org/example/App.java new file mode 100644 index 0000000..5f21d2e --- /dev/null +++ b/MyPic/src/main/java/org/example/App.java @@ -0,0 +1,13 @@ +package org.example; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/MyPic/src/test/java/org/example/AppTest.java b/MyPic/src/test/java/org/example/AppTest.java new file mode 100644 index 0000000..d5f435d --- /dev/null +++ b/MyPic/src/test/java/org/example/AppTest.java @@ -0,0 +1,38 @@ +package org.example; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/interface/pom.xml b/interface/pom.xml new file mode 100644 index 0000000..c2b50d4 --- /dev/null +++ b/interface/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + org.example + interface + 1.0-SNAPSHOT + jar + + interface + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/interface/src/main/java/org/example/App.java b/interface/src/main/java/org/example/App.java new file mode 100644 index 0000000..5f21d2e --- /dev/null +++ b/interface/src/main/java/org/example/App.java @@ -0,0 +1,13 @@ +package org.example; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/interface/src/test/java/org/example/AppTest.java b/interface/src/test/java/org/example/AppTest.java new file mode 100644 index 0000000..d5f435d --- /dev/null +++ b/interface/src/test/java/org/example/AppTest.java @@ -0,0 +1,38 @@ +package org.example; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/w6/pom.xml b/w6/pom.xml new file mode 100644 index 0000000..d6950e4 --- /dev/null +++ b/w6/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + org.example + w6 + 1.0-SNAPSHOT + jar + + w6 + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/w6/src/main/java/com/w6/Animal.java b/w6/src/main/java/com/w6/Animal.java new file mode 100644 index 0000000..1a857ce --- /dev/null +++ b/w6/src/main/java/com/w6/Animal.java @@ -0,0 +1,5 @@ +package com.w6; + +public abstract class Animal { + abstract void makeSound(); +} diff --git a/w6/src/main/java/com/w6/Cat.java b/w6/src/main/java/com/w6/Cat.java new file mode 100644 index 0000000..6663df7 --- /dev/null +++ b/w6/src/main/java/com/w6/Cat.java @@ -0,0 +1,8 @@ +package com.w6; + +public class Cat extends Animal{ + @Override + public void makeSound(){ + System.out.println("喵喵喵"); + } +} diff --git a/w6/src/main/java/com/w6/Dog.java b/w6/src/main/java/com/w6/Dog.java new file mode 100644 index 0000000..e0b358f --- /dev/null +++ b/w6/src/main/java/com/w6/Dog.java @@ -0,0 +1,11 @@ +package com.w6; + +public class Dog extends Animal implements Swimmable{ + @Override + public void makeSound() { + System.out.println("汪汪汪"); + } + public void swim(){ + System.out.println("狗会游泳"); + } +} diff --git a/w6/src/main/java/com/w6/Main.java b/w6/src/main/java/com/w6/Main.java new file mode 100644 index 0000000..5f187ae --- /dev/null +++ b/w6/src/main/java/com/w6/Main.java @@ -0,0 +1,18 @@ +package com.w6; + +public class Main { + public static void main (String []args){ + Animal[] animals=new Animal[2]; + animals[0]=new Dog(); + animals[1]=new Cat(); + for(Animal a: animals){ + a.makeSound(); + if(a instanceof Swimmable){ + ((Swimmable)a).swim(); + } + else{ + System.out.println("该动物不能游泳"); + } + } + } +} diff --git a/w6/src/main/java/com/w6/Swimmable.java b/w6/src/main/java/com/w6/Swimmable.java new file mode 100644 index 0000000..5631366 --- /dev/null +++ b/w6/src/main/java/com/w6/Swimmable.java @@ -0,0 +1,5 @@ +package com.w6; + +public interface Swimmable { + void swim(); +} diff --git a/w6/src/main/java/org/example/App.java b/w6/src/main/java/org/example/App.java new file mode 100644 index 0000000..5f21d2e --- /dev/null +++ b/w6/src/main/java/org/example/App.java @@ -0,0 +1,13 @@ +package org.example; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/w6/src/test/java/org/example/AppTest.java b/w6/src/test/java/org/example/AppTest.java new file mode 100644 index 0000000..d5f435d --- /dev/null +++ b/w6/src/test/java/org/example/AppTest.java @@ -0,0 +1,38 @@ +package org.example; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/w6/target/classes/com/w5/Animal.class b/w6/target/classes/com/w5/Animal.class new file mode 100644 index 0000000000000000000000000000000000000000..7f37112e307aba782bce0d884c2536576038d663 GIT binary patch literal 277 zcmY*TyKcfj5S+CSjLn-rpaY6rlT<{JA|xsV1&ID^PH@IPOO7Gml`2w-d_X=bVh?E8 zVn#c&nw`J@pI-pa=tuD22M{gPP$%?KbyhM{b}v_Ps*{RPe>K)rZv=ld-Uet8+DVbi z&lmY_O|CM6m=!xs=q`-a%Tpffa--smmBFG&RJK*6ar<2q)xmtY>xYynAK{(b<5HCS&V%z}yA|&|w#> Ibs0VME_=r{EdT%j literal 0 HcmV?d00001 diff --git a/w6/target/classes/com/w5/Cat.class b/w6/target/classes/com/w5/Cat.class new file mode 100644 index 0000000000000000000000000000000000000000..4b08d018db6c1f40bbfb358b01f3b47591533003 GIT binary patch literal 469 zcmZvZOG*Pl5QhKCt7pcEiHY(3z+K|P*(fd|f&^R*B1E$9Bu#9chfF4l7x5knD!A|f z-otB%)k#QP*fdpC{Z(HT-CsW+p8yWA>mY-yK+Z)T1wyeGhu*`HcNXbT286xdrBv5ft#WJD#Pd!20neHHBV0}WI%t|>uXf`?mD+Fh{a7*&wTr2J?Ldn;Wx)_CB zm0Zbgz?q64_hitKi8k>xnM<$rkl^}rM3Z2L@>aFuQPgKR`=qDNwP9F1;=nA5J=FNs z%*lYvyRlv6$YW3J^ZW0h=drxT*2q8>>ulXg0XDG75n*fAd_0B$_6tO%_=eIPVE)Kp PEQmi4dj{ENHG`dBSiM?> literal 0 HcmV?d00001 diff --git a/w6/target/classes/com/w5/Dog.class b/w6/target/classes/com/w5/Dog.class new file mode 100644 index 0000000000000000000000000000000000000000..c91b3a3ca227e26d2ff6bd3391b18e0302716c00 GIT binary patch literal 590 zcmZvZOG*Pl5QhIwV&>s!H1Yj@EfN>bMsX1lL~%8UFp_P(0(2AZm_uIlgas{Z_W`v9 zhz2QHf8a7Tsc=*lPwpah~@H~s@wiu?p)jCfy}M2*ulx4j?d+;i`HpMJgH1~80E24YY+R1+E+ z7?N}1zQ|XFSIJM!%-Q9Tq2aRQIpH{ilI<>W#2FgPzMEej$zSmtS5!F+2BQ|b>Q@Zt zlCkkma6*IzOeh98k|qwxM!GBJZOdQsW;t4@Zw+rPJFY8cs&)b?q)oKST6K}4I*ua4 zam>VVocKqm^3`0vDI0IjhWL1wyvIh;K9TB_ZRSI%1XBiT;Atr@Gh3bSq zYcn(#9nZe8YT&>yZdR-ZqkR586 zgY%Fm5mbn*r4EQj5z(7atLea(^bbva(Y+!8v_ zMb}3@F)(?7$etrFPhUn~t!EwVO_a`(m1#ghH(B$b06oZ&r=u5r6p`Q^s8k7*v@P&r zPT7QhcO3~Ur*6Weza}d;*}FZijH+q1?KuW|)9T=umeJPGoY6ia^$f|3_5rDPILxqu z#9JImwXNaQBbBY}f0k+#NHsk$$ZC=7X1bXf#7TpWL5hzdf$M0(6vgh)g_Vli3D<{C y^wW46`6ZmkK*Vs1Fhit%II2?jX)hYb2*)VBjAs6cE)MK+z7k>kPz`!{G literal 0 HcmV?d00001 diff --git a/w6/target/classes/com/w5/Swimmable.class b/w6/target/classes/com/w5/Swimmable.class new file mode 100644 index 0000000000000000000000000000000000000000..7f6fed9ac95d6ff42ff120521e7ff4e96d770a54 GIT binary patch literal 127 zcmX^0Z`VEs1_l!bPId++Mh1c8{9OHVQ~lub%-r0>q?}ZC1{R=bR$^JAeokUuy1su> zR%&tyBLhn@Pz56cvxa6EBLi1(erZv1s#|7GDkB3QT(2HT8yh17P#Mq)1_nl;QLGGX NAQl5VkYr-u003GS8?gWY literal 0 HcmV?d00001 diff --git a/w6/target/classes/org/example/App.class b/w6/target/classes/org/example/App.class new file mode 100644 index 0000000000000000000000000000000000000000..4240a01294e24f2c4b7e84ad3e0ce9c8b170e898 GIT binary patch literal 537 zcmZvZ$w~u35QhKGHjAU#Ox!i`lz4D1f`^D8f_NBIh{S`ZPST7WW~PV9MD(%rpy0s= z@S()&LQWOj)x0T4D)%OlQQA!t!NZP;6$a;01c7SYsU#RS zZIn`|SeK{12o4@%f?F#rGn literal 0 HcmV?d00001 diff --git a/实验一CarProject/pom.xml b/实验一CarProject/pom.xml new file mode 100644 index 0000000..c95bd33 --- /dev/null +++ b/实验一CarProject/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + org.example + 实验一CarProject + 1.0-SNAPSHOT + jar + + CarProject + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/实验一CarProject/src/main/java/org/example/App.java b/实验一CarProject/src/main/java/org/example/App.java new file mode 100644 index 0000000..5f21d2e --- /dev/null +++ b/实验一CarProject/src/main/java/org/example/App.java @@ -0,0 +1,13 @@ +package org.example; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/实验一CarProject/src/test/java/org/example/AppTest.java b/实验一CarProject/src/test/java/org/example/AppTest.java new file mode 100644 index 0000000..d5f435d --- /dev/null +++ b/实验一CarProject/src/test/java/org/example/AppTest.java @@ -0,0 +1,38 @@ +package org.example; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +}