34 changed files with 306 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<groupId>org.example</groupId> |
|||
<artifactId>Person</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
<packaging>jar</packaging> |
|||
|
|||
<name>Person</name> |
|||
<url>http://maven.apache.org</url> |
|||
|
|||
<properties> |
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|||
</properties> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<version>3.8.1</version> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,13 @@ |
|||
package org.example; |
|||
|
|||
/** |
|||
* Hello world! |
|||
* |
|||
*/ |
|||
public class App |
|||
{ |
|||
public static void main( String[] args ) |
|||
{ |
|||
System.out.println( "Hello World!" ); |
|||
} |
|||
} |
|||
@ -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 ); |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<groupId>org.example</groupId> |
|||
<artifactId>w5</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
<packaging>jar</packaging> |
|||
|
|||
<name>BasicProblem</name> |
|||
<url>http://maven.apache.org</url> |
|||
|
|||
<properties> |
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|||
</properties> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<version>3.8.1</version> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,8 @@ |
|||
package com.practice.advanced_problem; |
|||
|
|||
public class Bike extends Vehicle{ |
|||
@Override |
|||
public void run() { |
|||
System.out.println("自行车在非机动车道上行驶。"); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
package com.practice.advanced_problem; |
|||
|
|||
public class Car extends Vehicle{ |
|||
@Override |
|||
public void run(){ |
|||
System.out.println("汽车在机动车道行驶。"); |
|||
} |
|||
} |
|||
@ -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(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
package com.practice.advanced_problem; |
|||
|
|||
public class Truck extends Vehicle{ |
|||
@Override |
|||
public void run(){ |
|||
System.out.println("卡车在货运通道上行驶。"); |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package com.practice.advanced_problem; |
|||
|
|||
public abstract class Vehicle { |
|||
public abstract void run(); |
|||
} |
|||
|
After Width: | Height: | Size: 9.8 KiB |
@ -0,0 +1,8 @@ |
|||
package com.practice.basic_problem; |
|||
|
|||
public class Circle extends Shape { |
|||
@Override |
|||
public void draw(){ |
|||
System.out.println("圆形形状: ○"); |
|||
} |
|||
} |
|||
@ -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); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
package com.practice.basic_problem; |
|||
|
|||
public class Rectangle extends Shape { |
|||
@Override |
|||
public void draw(){ |
|||
System.out.println("矩形: ▭"); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
package com.practice.basic_problem; |
|||
|
|||
public class Shape { |
|||
public void draw() { |
|||
System.out.println("绘制任意图形"); |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 3.1 KiB |
@ -0,0 +1,13 @@ |
|||
package org.example; |
|||
|
|||
/** |
|||
* Hello world! |
|||
* |
|||
*/ |
|||
public class App |
|||
{ |
|||
public static void main( String[] args ) |
|||
{ |
|||
System.out.println( "Hello World!" ); |
|||
} |
|||
} |
|||
@ -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 ); |
|||
} |
|||
} |
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@ |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<groupId>org.example</groupId> |
|||
<artifactId>封装继承多态</artifactId> |
|||
<version>1.0-SNAPSHOT</version> |
|||
<packaging>jar</packaging> |
|||
|
|||
<name>untitled</name> |
|||
<url>http://maven.apache.org</url> |
|||
|
|||
<properties> |
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|||
</properties> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>junit</groupId> |
|||
<artifactId>junit</artifactId> |
|||
<version>3.8.1</version> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,13 @@ |
|||
package org.example; |
|||
|
|||
/** |
|||
* Hello world! |
|||
* |
|||
*/ |
|||
public class App |
|||
{ |
|||
public static void main( String[] args ) |
|||
{ |
|||
System.out.println( "Hello World!" ); |
|||
} |
|||
} |
|||
@ -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 ); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue