diff --git a/Person/pom.xml b/Person/pom.xml new file mode 100644 index 0000000..3bd59cf --- /dev/null +++ b/Person/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + org.example + Person + 1.0-SNAPSHOT + jar + + Person + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/Person/src/main/java/org/example/App.java b/Person/src/main/java/org/example/App.java new file mode 100644 index 0000000..5f21d2e --- /dev/null +++ b/Person/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/Person/src/test/java/org/example/AppTest.java b/Person/src/test/java/org/example/AppTest.java new file mode 100644 index 0000000..d5f435d --- /dev/null +++ b/Person/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/w5/pom.xml b/w5/pom.xml new file mode 100644 index 0000000..130f5de --- /dev/null +++ b/w5/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + org.example + w5 + 1.0-SNAPSHOT + jar + + BasicProblem + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/w5/src/main/java/com/practice/advanced_problem/Bike.java b/w5/src/main/java/com/practice/advanced_problem/Bike.java new file mode 100644 index 0000000..f5961ff --- /dev/null +++ b/w5/src/main/java/com/practice/advanced_problem/Bike.java @@ -0,0 +1,8 @@ +package com.practice.advanced_problem; + +public class Bike extends Vehicle{ + @Override + public void run() { + System.out.println("自行车在非机动车道上行驶。"); + } +} diff --git a/w5/src/main/java/com/practice/advanced_problem/Car.java b/w5/src/main/java/com/practice/advanced_problem/Car.java new file mode 100644 index 0000000..7240c26 --- /dev/null +++ b/w5/src/main/java/com/practice/advanced_problem/Car.java @@ -0,0 +1,8 @@ +package com.practice.advanced_problem; + +public class Car extends Vehicle{ + @Override + public void run(){ + System.out.println("汽车在机动车道行驶。"); + } +} diff --git a/w5/src/main/java/com/practice/advanced_problem/Main.java b/w5/src/main/java/com/practice/advanced_problem/Main.java new file mode 100644 index 0000000..7275ecd --- /dev/null +++ b/w5/src/main/java/com/practice/advanced_problem/Main.java @@ -0,0 +1,13 @@ +package com.practice.advanced_problem; + +public class Main { + public static void main(String []args){ + Vehicle[] vehicles=new Vehicle[3]; + vehicles[0]=new Car(); + vehicles[1]=new Bike(); + vehicles[2]=new Truck(); + for(Vehicle v : vehicles){ + v.run(); + } + } +} diff --git a/w5/src/main/java/com/practice/advanced_problem/Truck.java b/w5/src/main/java/com/practice/advanced_problem/Truck.java new file mode 100644 index 0000000..77e93ce --- /dev/null +++ b/w5/src/main/java/com/practice/advanced_problem/Truck.java @@ -0,0 +1,8 @@ +package com.practice.advanced_problem; + +public class Truck extends Vehicle{ + @Override + public void run(){ + System.out.println("卡车在货运通道上行驶。"); + } +} diff --git a/w5/src/main/java/com/practice/advanced_problem/Vehicle.java b/w5/src/main/java/com/practice/advanced_problem/Vehicle.java new file mode 100644 index 0000000..361e20d --- /dev/null +++ b/w5/src/main/java/com/practice/advanced_problem/Vehicle.java @@ -0,0 +1,5 @@ +package com.practice.advanced_problem; + +public abstract class Vehicle { + public abstract void run(); +} diff --git a/w5/src/main/java/com/practice/advanced_problem/运行截图.png b/w5/src/main/java/com/practice/advanced_problem/运行截图.png new file mode 100644 index 0000000..3008bdf Binary files /dev/null and b/w5/src/main/java/com/practice/advanced_problem/运行截图.png differ diff --git a/w5/src/main/java/com/practice/basic_problem/Circle.java b/w5/src/main/java/com/practice/basic_problem/Circle.java new file mode 100644 index 0000000..900df8f --- /dev/null +++ b/w5/src/main/java/com/practice/basic_problem/Circle.java @@ -0,0 +1,8 @@ +package com.practice.basic_problem; + +public class Circle extends Shape { + @Override + public void draw(){ + System.out.println("圆形形状: ○"); + } +} diff --git a/w5/src/main/java/com/practice/basic_problem/Main.java b/w5/src/main/java/com/practice/basic_problem/Main.java new file mode 100644 index 0000000..bd6654f --- /dev/null +++ b/w5/src/main/java/com/practice/basic_problem/Main.java @@ -0,0 +1,13 @@ +package com.practice.basic_problem; + +public class Main { + public static void drawShape(Shape s){ + s.draw(); + } + public static void main(String []args){ + Shape circle=new Circle(); + Shape rect=new Rectangle(); + drawShape(circle); + drawShape(rect); + } +} diff --git a/w5/src/main/java/com/practice/basic_problem/Rectangle.java b/w5/src/main/java/com/practice/basic_problem/Rectangle.java new file mode 100644 index 0000000..1d8b66b --- /dev/null +++ b/w5/src/main/java/com/practice/basic_problem/Rectangle.java @@ -0,0 +1,8 @@ +package com.practice.basic_problem; + +public class Rectangle extends Shape { + @Override + public void draw(){ + System.out.println("矩形: ▭"); + } +} diff --git a/w5/src/main/java/com/practice/basic_problem/Shape.java b/w5/src/main/java/com/practice/basic_problem/Shape.java new file mode 100644 index 0000000..4bbd756 --- /dev/null +++ b/w5/src/main/java/com/practice/basic_problem/Shape.java @@ -0,0 +1,7 @@ +package com.practice.basic_problem; + +public class Shape { + public void draw() { + System.out.println("绘制任意图形"); + } +} diff --git a/w5/src/main/java/com/practice/basic_problem/运行截图.png b/w5/src/main/java/com/practice/basic_problem/运行截图.png new file mode 100644 index 0000000..28b6a73 Binary files /dev/null and b/w5/src/main/java/com/practice/basic_problem/运行截图.png differ diff --git a/w5/src/main/java/org/example/App.java b/w5/src/main/java/org/example/App.java new file mode 100644 index 0000000..5f21d2e --- /dev/null +++ b/w5/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/w5/src/test/java/org/example/AppTest.java b/w5/src/test/java/org/example/AppTest.java new file mode 100644 index 0000000..d5f435d --- /dev/null +++ b/w5/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/w5/target/classes/com/example/Circle.class b/w5/target/classes/com/example/Circle.class new file mode 100644 index 0000000..615a6c6 Binary files /dev/null and b/w5/target/classes/com/example/Circle.class differ diff --git a/w5/target/classes/com/example/Main.class b/w5/target/classes/com/example/Main.class new file mode 100644 index 0000000..f5b26a2 Binary files /dev/null and b/w5/target/classes/com/example/Main.class differ diff --git a/w5/target/classes/com/example/Rectangle.class b/w5/target/classes/com/example/Rectangle.class new file mode 100644 index 0000000..e500553 Binary files /dev/null and b/w5/target/classes/com/example/Rectangle.class differ diff --git a/w5/target/classes/com/example/Shape.class b/w5/target/classes/com/example/Shape.class new file mode 100644 index 0000000..f62c796 Binary files /dev/null and b/w5/target/classes/com/example/Shape.class differ diff --git a/w5/target/classes/com/practice/基础题/Circle.class b/w5/target/classes/com/practice/基础题/Circle.class new file mode 100644 index 0000000..4a8e3f5 Binary files /dev/null and b/w5/target/classes/com/practice/基础题/Circle.class differ diff --git a/w5/target/classes/com/practice/基础题/Main.class b/w5/target/classes/com/practice/基础题/Main.class new file mode 100644 index 0000000..ef4efcb Binary files /dev/null and b/w5/target/classes/com/practice/基础题/Main.class differ diff --git a/w5/target/classes/com/practice/基础题/Rectangle.class b/w5/target/classes/com/practice/基础题/Rectangle.class new file mode 100644 index 0000000..e0e1443 Binary files /dev/null and b/w5/target/classes/com/practice/基础题/Rectangle.class differ diff --git a/w5/target/classes/com/practice/基础题/Shape.class b/w5/target/classes/com/practice/基础题/Shape.class new file mode 100644 index 0000000..ba02b98 Binary files /dev/null and b/w5/target/classes/com/practice/基础题/Shape.class differ diff --git a/w5/target/classes/com/practice/进阶题/Bike.class b/w5/target/classes/com/practice/进阶题/Bike.class new file mode 100644 index 0000000..c30c7bb Binary files /dev/null and b/w5/target/classes/com/practice/进阶题/Bike.class differ diff --git a/w5/target/classes/com/practice/进阶题/Car.class b/w5/target/classes/com/practice/进阶题/Car.class new file mode 100644 index 0000000..f4e1631 Binary files /dev/null and b/w5/target/classes/com/practice/进阶题/Car.class differ diff --git a/w5/target/classes/com/practice/进阶题/Main.class b/w5/target/classes/com/practice/进阶题/Main.class new file mode 100644 index 0000000..585a9de Binary files /dev/null and b/w5/target/classes/com/practice/进阶题/Main.class differ diff --git a/w5/target/classes/com/practice/进阶题/Truck.class b/w5/target/classes/com/practice/进阶题/Truck.class new file mode 100644 index 0000000..ad8627f Binary files /dev/null and b/w5/target/classes/com/practice/进阶题/Truck.class differ diff --git a/w5/target/classes/com/practice/进阶题/Vehicle.class b/w5/target/classes/com/practice/进阶题/Vehicle.class new file mode 100644 index 0000000..d19c638 Binary files /dev/null and b/w5/target/classes/com/practice/进阶题/Vehicle.class differ diff --git a/w5/target/classes/org/example/App.class b/w5/target/classes/org/example/App.class new file mode 100644 index 0000000..4240a01 Binary files /dev/null and b/w5/target/classes/org/example/App.class differ diff --git a/封装继承多态/pom.xml b/封装继承多态/pom.xml new file mode 100644 index 0000000..78426ca --- /dev/null +++ b/封装继承多态/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + org.example + 封装继承多态 + 1.0-SNAPSHOT + jar + + untitled + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/封装继承多态/src/main/java/org/example/App.java b/封装继承多态/src/main/java/org/example/App.java new file mode 100644 index 0000000..5f21d2e --- /dev/null +++ b/封装继承多态/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/封装继承多态/src/test/java/org/example/AppTest.java b/封装继承多态/src/test/java/org/example/AppTest.java new file mode 100644 index 0000000..d5f435d --- /dev/null +++ b/封装继承多态/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 ); + } +}