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 0000000..7f37112 Binary files /dev/null and b/w6/target/classes/com/w5/Animal.class differ diff --git a/w6/target/classes/com/w5/Cat.class b/w6/target/classes/com/w5/Cat.class new file mode 100644 index 0000000..4b08d01 Binary files /dev/null and b/w6/target/classes/com/w5/Cat.class differ diff --git a/w6/target/classes/com/w5/Dog.class b/w6/target/classes/com/w5/Dog.class new file mode 100644 index 0000000..c91b3a3 Binary files /dev/null and b/w6/target/classes/com/w5/Dog.class differ diff --git a/w6/target/classes/com/w5/Main.class b/w6/target/classes/com/w5/Main.class new file mode 100644 index 0000000..fa0f7f3 Binary files /dev/null and b/w6/target/classes/com/w5/Main.class differ diff --git a/w6/target/classes/com/w5/Swimmable.class b/w6/target/classes/com/w5/Swimmable.class new file mode 100644 index 0000000..7f6fed9 Binary files /dev/null and b/w6/target/classes/com/w5/Swimmable.class differ diff --git a/w6/target/classes/org/example/App.class b/w6/target/classes/org/example/App.class new file mode 100644 index 0000000..4240a01 Binary files /dev/null and b/w6/target/classes/org/example/App.class differ 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 ); + } +}