Browse Source

王烊烊202302050115w5

master
WangYangyang 2 weeks ago
parent
commit
51d479427c
  1. 25
      Person/pom.xml
  2. 13
      Person/src/main/java/org/example/App.java
  3. 38
      Person/src/test/java/org/example/AppTest.java
  4. 25
      w5/pom.xml
  5. 8
      w5/src/main/java/com/practice/advanced_problem/Bike.java
  6. 8
      w5/src/main/java/com/practice/advanced_problem/Car.java
  7. 13
      w5/src/main/java/com/practice/advanced_problem/Main.java
  8. 8
      w5/src/main/java/com/practice/advanced_problem/Truck.java
  9. 5
      w5/src/main/java/com/practice/advanced_problem/Vehicle.java
  10. BIN
      w5/src/main/java/com/practice/advanced_problem/运行截图.png
  11. 8
      w5/src/main/java/com/practice/basic_problem/Circle.java
  12. 13
      w5/src/main/java/com/practice/basic_problem/Main.java
  13. 8
      w5/src/main/java/com/practice/basic_problem/Rectangle.java
  14. 7
      w5/src/main/java/com/practice/basic_problem/Shape.java
  15. BIN
      w5/src/main/java/com/practice/basic_problem/运行截图.png
  16. 13
      w5/src/main/java/org/example/App.java
  17. 38
      w5/src/test/java/org/example/AppTest.java
  18. BIN
      w5/target/classes/com/example/Circle.class
  19. BIN
      w5/target/classes/com/example/Main.class
  20. BIN
      w5/target/classes/com/example/Rectangle.class
  21. BIN
      w5/target/classes/com/example/Shape.class
  22. BIN
      w5/target/classes/com/practice/基础题/Circle.class
  23. BIN
      w5/target/classes/com/practice/基础题/Main.class
  24. BIN
      w5/target/classes/com/practice/基础题/Rectangle.class
  25. BIN
      w5/target/classes/com/practice/基础题/Shape.class
  26. BIN
      w5/target/classes/com/practice/进阶题/Bike.class
  27. BIN
      w5/target/classes/com/practice/进阶题/Car.class
  28. BIN
      w5/target/classes/com/practice/进阶题/Main.class
  29. BIN
      w5/target/classes/com/practice/进阶题/Truck.class
  30. BIN
      w5/target/classes/com/practice/进阶题/Vehicle.class
  31. BIN
      w5/target/classes/org/example/App.class
  32. 25
      封装继承多态/pom.xml
  33. 13
      封装继承多态/src/main/java/org/example/App.java
  34. 38
      封装继承多态/src/test/java/org/example/AppTest.java

25
Person/pom.xml

@ -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>

13
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!" );
}
}

38
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 );
}
}

25
w5/pom.xml

@ -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>

8
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("自行车在非机动车道上行驶。");
}
}

8
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("汽车在机动车道行驶。");
}
}

13
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();
}
}
}

8
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("卡车在货运通道上行驶。");
}
}

5
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();
}

BIN
w5/src/main/java/com/practice/advanced_problem/运行截图.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

8
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("圆形形状: ○");
}
}

13
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);
}
}

8
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("矩形: ▭");
}
}

7
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("绘制任意图形");
}
}

BIN
w5/src/main/java/com/practice/basic_problem/运行截图.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

13
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!" );
}
}

38
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 );
}
}

BIN
w5/target/classes/com/example/Circle.class

Binary file not shown.

BIN
w5/target/classes/com/example/Main.class

Binary file not shown.

BIN
w5/target/classes/com/example/Rectangle.class

Binary file not shown.

BIN
w5/target/classes/com/example/Shape.class

Binary file not shown.

BIN
w5/target/classes/com/practice/基础题/Circle.class

Binary file not shown.

BIN
w5/target/classes/com/practice/基础题/Main.class

Binary file not shown.

BIN
w5/target/classes/com/practice/基础题/Rectangle.class

Binary file not shown.

BIN
w5/target/classes/com/practice/基础题/Shape.class

Binary file not shown.

BIN
w5/target/classes/com/practice/进阶题/Bike.class

Binary file not shown.

BIN
w5/target/classes/com/practice/进阶题/Car.class

Binary file not shown.

BIN
w5/target/classes/com/practice/进阶题/Main.class

Binary file not shown.

BIN
w5/target/classes/com/practice/进阶题/Truck.class

Binary file not shown.

BIN
w5/target/classes/com/practice/进阶题/Vehicle.class

Binary file not shown.

BIN
w5/target/classes/org/example/App.class

Binary file not shown.

25
封装继承多态/pom.xml

@ -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>

13
封装继承多态/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!" );
}
}

38
封装继承多态/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 );
}
}
Loading…
Cancel
Save